Greasy Fork

Greasy Fork is available in English.

Bing首页优化

Bing首页优化,去除bing首页的国内版和国际版切换标签,去除底部的版权信息和广告链接,保留首页壁纸切换按钮。

目前为 2023-10-06 提交的版本,查看 最新版本

// ==UserScript==
// @name        Bing首页优化
// @namespace   Bing首页优化
// @description Bing首页优化,去除bing首页的国内版和国际版切换标签,去除底部的版权信息和广告链接,保留首页壁纸切换按钮。
// @author      girl
// @icon        https://favicon.yandex.net/favicon/v2/bing.com
// @include     *://cn.bing.com/
// @include     *://cn.bing.com/chrome/newtab
// @version     1.0.14
// @license     GPL-3.0-only
// @home-url    http://greasyfork.icu/zh-CN/scripts/430997
// ==/UserScript==
//


(function() {

	var timeFunction = window.setInterval(function(){loadEnd()},1);
	function loadEnd(){
		var footer = document.querySelector('#footer');
		var searchNav = document.querySelector('#est_switch');
		var searchBox = document.querySelector('.sb_form_q');
		var sbox = document.querySelector('.sbox');
		var headline = document.querySelector('#headline');
		var hp_trivia_inner = document.querySelector('.hp_trivia_inner');
		var id_rh = document.querySelector('#id_rh');
		var id_qrcode = document.querySelector('#id_qrcode');
		var sa_zis_PN = document.querySelector('#sa_zis_PN');//去除cn.bing.com主页“今日热点”
		var sa_ul = document.getElementById('sa_ul');//去除新标签页“今日热点”

   		
        if (true) {
            document.documentElement.style.overflowY = "hidden"
   		}

		if (footer){
			hidenDom(footer);
		}
		if (searchNav){
			hidenDom(searchNav);
		}

		if (sbox){
			sbox.style.margin='0';
            sbox.style.top = "30%"; // 设置位置
            sbox.style.left = "30%";
        }
        if (headline){
        	hidenDom(headline);
        }
        if (hp_trivia_inner){
        	hidenDom(hp_trivia_inner);
        }
        if (id_rh) {
        	hidenDom(id_rh);
        }
        if (id_qrcode) {
    	    hidenDom(id_qrcode);
        }
	    //去除主页cn.bing.com搜索框内部 “今日热点”
	    if (sa_zis_PN) {
	    	hidenDom(sa_zis_PN);
	    }
	    //去除新标签页搜索框内部 “今日热点”
	    if (sa_ul) {
	    	var sa_ul_child = sa_ul.children;
 
	    	for (var i = 0; i < sa_ul_child.length; i++) {
	    		if (sa_ul_child[i].className == 'sa_hd'){
	    			for (var j = i; j < sa_ul_child.length; j++){
	    				hidenDom(sa_ul_child[j]);
	    			}
	    			break;
	    		}
	    	}
	    }


    }

    function removeDom(dom){
    	if(dom){
    		dom.remove();
    	}
    }

    function hidenDom(dom){
    	if(dom){
    		dom.style.display = 'none';
    	}
    }

    function SearchBoxEditor(){ // 修改搜索框

	    var searchbox= document.querySelector('#sb_form_q');
	    var searchLabel = document.querySelector('#sb_form');

      	searchLabel.style.backgroundColor = "#FFFFFF00";

     	function SearchBoxOnFocus(){
        	searchLabel.style.backgroundColor = "#FFFFFF";
        }

      	function SearchBoxOnBlur(){
        	searchLabel.style.backgroundColor = "#FFFFFF00";
        }

      	function SearchBoxOnMouseOver(){
      		if(document.activeElement.id == "sb_form_q"){
         	 	// still
         	 	searchLabel.style.backgroundColor = "#FFFFFF";
         	 }else{
         		searchLabel.style.backgroundColor = "#FFFFFF00";
         	}
         }

      	function SearchBoxOnMouseLeave(){
      		if(document.activeElement.id == "sb_form_q"){
          		// still
          	}else{
          		searchLabel.style.backgroundColor = "#FFFFFF00";
          	}
          }

      	searchbox.onblur = SearchBoxOnBlur; // 失去焦点
      	searchbox.onfocus = SearchBoxOnFocus; // 获得焦点
      	searchbox.onclick = SearchBoxOnFocus;// 点击事件
      	searchLabel.onclick = SearchBoxOnFocus; // 点击事件
      	searchLabel.onmouseover = SearchBoxOnMouseOver; // 鼠标滑过
     	searchLabel.onmouseleave = SearchBoxOnMouseLeave; // 鼠标离开 = 失去焦点

     }

    window.setTimeout(SearchBoxEditor,10); // 初始化函数

})();