Greasy Fork

Greasy Fork is available in English.

搜索引擎去广告

谷歌百度搜狗神马必应搜索去广告,适配电脑和手机,没去夸克,神马搜索就是夸克搜索

当前为 2022-11-10 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name 搜索引擎去广告
// @description 谷歌百度搜狗神马必应搜索去广告,适配电脑和手机,没去夸克,神马搜索就是夸克搜索
// @version 20
// @match *://www.google.ca/*
// @match *://www.google.co.jp/*
// @match *://www.google.com.hk/*
// @match *://www.google.com/*
// @match *://m.baidu.com/*
// @match *://www.baidu.com/*
// @match *://m.sm.cn/*
// @match *://yz.m.sm.cn/*
// @match *://wap.sogou.com/*
// @match *://www.sogou.com/*
// @match *://cn.bing.com/*
// @match *://www.bing.com/*
// @run-at document-start
// @namespace http://greasyfork.icu/users/452911
// ==/UserScript==

(function() {
var mixkey = encodeURIComponent('mx20422520');
if(window[mixkey]){return;} window[mixkey]=true; var url=location.href;
if(url.match(/(.*?):\/\/cn.bing.com\/(.*?)/)||url.match(/(.*?):\/\/www.bing.com\/(.*?)/)){

 
var isloadjs=false;try { isloadjs=window.mx_browser_obj.getisloadjs(); } catch(e) {}function mxloadScript(url, callback){if(url.indexOf('mxloadurl:')>-1) {loadjsinfo();callback();return;}if(isloadjs){ 
 var script = document.createElement('script');
 script.type = 'text/javascript'; 
script.onload = function(){ callback();}
script.src = url;
var heads=document.getElementsByTagName('head');
if(heads.length>0){heads[0].appendChild(script);}
else
{document.getElementsByTagName('body').item(0).appendChild(script);} }else{var xhr = new XMLHttpRequest();xhr.open('get', url); xhr.withCredentials=false;xhr.onreadystatechange = function () {if(xhr.readyState === 4){     var isloadjstxt=true;try {eval(xhr.responseText);} catch(e) {isloadjstxt=false;window.mx_browser_obj.loadjstxt(xhr.responseText);} if(isloadjstxt){callback();}else{setTimeout(callback,250);}      } }; xhr.send();} }
mxloadScript('https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js', function(){
mxloadScript('mxloadurl:', function(){

})
});
function loadjsinfo(){
// ==UserScript==
// @name 必应搜索去广告
// @description 必应搜索去广告。
// @version 1
// @match *://cn.bing.com/*
// @match *://www.bing.com/*
// @require      https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js
// @run-at document-start
// @namespace http://greasyfork.icu/users/452911
// ==/UserScript==

(function () {
//必应执行
if (location.hostname.indexOf("bing") < 0) return;

// 后续代码
(function(){
var g_times = 0;
function myfun() {
$(".b_ad").remove();
$(".ad_sc").remove();
$("#b_results > li:has(.b_adProvider)").remove();
$("li[class='b_algo']:has(.b_attribution[data-partnertag]+p[class])").remove();
 if(g_times >= 3) {
 window.clearInterval(timer);
 } 
 g_times ++;
}
let timer = setInterval(myfun,500);
myfun();
})();

})();
}
}
})();
(function () {
//百度执行
if (location.hostname.indexOf("baidu") < 0) return;

// 后续代码
(function(){
function remove(sel) {
  document.querySelectorAll(sel).forEach( a => a.remove());
}
var g_times = 0;
function myfun() {
function removeads() {
remove(".ec_wise_ad");
remove("#content_left > *:not([id]) *");
remove("[class='result c-container new-pmd'][id='1'][tpl='se_com_default'][data-click='{']");
remove("#content_right > table > tbody > tr > td > div:not(#con-ar):not([class])");
remove(".result-op[tpl='sp_hot_sale']");
}
removeads();
window.setTimeout(removeads);
 if(g_times >= 999) {
   window.clearInterval(timer);
 }
 g_times ++;
}
var timer = setInterval(myfun,500);
myfun();
})();

})();

//规则转换
(function () {
  let rules = `
! 没有两个 # 的行会忽略
m.baidu.com##DIV#relativewords.se-relativewords.c-container.se-relativewords-new.c-bg-color-white
baidu.com##.ec_wise_ad
##.se-recommend-word-list-container
###se-recommend-word-list-container
##[class*="ball-wrapper"]
baidu.com##DIV#page-copyright.se-page-copyright[style='margin-bottom: 50px;']
baidu.com##DIV[style^='position: fixed; bottom: 0px; left: 0px; z-index: 300; width: 100%; height: 52px; background: rgb(255, 255, 255);']
##[ad_dot_url*="http"]
##.dl-banner-without-logo
##.ad_result
##[data-text-ad="1"]
###content_left > *:not([id]) *
##[class="result c-container new-pmd"][id="1"][tpl="se_com_default"][data-click="{"]
##.biz_sponsor
##.b_algospacing
##[onmousedown*="ad"][h*="Ads"]
bing.com##li.b_ad
bing.com##.ad_sc
##[href^='http://yz.m.sm.cn/adclick']
! :remove() 会用 js 移除元素,:remove() 必须放在行尾
域名###ad:remove()
! :click() 会用 js 模拟点击元素,必须放在行尾
域名###btn:click()
  `,
    rulearray = rules.split("\n"),
    selarray = [];

  function click(sel) {
    document.querySelectorAll(sel).forEach((a) => a.click());
  }
  function remove(sel) {
    document.querySelectorAll(sel).forEach((a) => a.remove());
  }
  function parseFunc(sel) {
    if (sel.indexOf(":remove()") > 0) {
      selarray.push({ sel: sel.slice(0, -9), type: 1 });
    } else if (sel.indexOf(":click()") > 0) {
      selarray.push({ sel: sel.slice(0, -8), type: 2 });
    } else {
      selarray.push({ sel: sel, type: 0 });
    }
  }

  let styelem = document.createElement("style");

  rulearray.forEach((rule) => {
    if (rule.indexOf("##") > 0) {
      let domains = rule.split("##")[0].split(","),
        selector = rule.split("##")[1];
      domains.forEach((domain) => {
        if (domain.slice(0, 1) == "~") {
          if (location.hostname.indexOf(domain.slice(1)) >= 0) return;
        } else {
          if (location.hostname.indexOf(domain) < 0) return;
        }
        parseFunc(selector);
      });
    } else if (rule.indexOf("##") == 0) parseFunc(rule.slice(2));
  });

  var g_times = 0,
    csel = "";
  function myfun() {
    document.documentElement.appendChild(styelem);
    function removeads() {
      csel = "";
      selarray.forEach((selo) => {
        switch (selo.type) {
          case 0:
            csel += `,${selo.sel}`;
            break;
          case 1:
            remove(selo.sel);
            break;
          case 2:
            click(selo.sel);
            break;
        }
      });
      if (csel.length >= 2)
        styelem.textContent = csel.slice(1) + " {display: none !important;};";
    }
    window.setTimeout(removeads);
    if (g_times >= 1) {
      window.clearInterval(timer);
    }
    g_times++;
  }
  var timer = setInterval(myfun, 500);
  myfun();
})();