// ==UserScript== // @name 【去广告 屏蔽广告 广告拦截 百度广告 百度联盟广告 谷歌广告】@LYS-广告拜拜助手(适配手机) // @namespace http://tampermonkey.net/ // @version 1.5 // @description 1、屏蔽百度搜索结果中插入广告;2、屏蔽百度联盟推广广告;3、屏蔽谷歌推广广告;4、屏蔽CSDN推广广告;5、可屏蔽自定义推广广告…… // @author LYS // @match */* // @icon none // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function () { 'use strict'; //自定义屏蔽广告推送规则 var ads = ["kunpeng-sc.csdnimg.cn/",//csdn广告推送 "pos.baidu.com/", //百度广告推送 "googleads.g.doubleclick.net", //谷歌广告推送 "pagead2.googlesyndication.com",//谷歌广告推送 "tpc.googlesyndication.com" //谷歌广告推送 ] for (var i = 0; i < ads.length; i++) { if (window.location.href.includes(ads[i])) { document.getElementsByTagName('head').innerHTML = ""; document.getElementsByTagName('title').innerHTML = ""; document.getElementsByTagName('body')[0].innerHTML = ""; break } } if (window.location.href.includes("www.baidu.com/")) { setInterval(function () { $('#content_left div:contains("广告")').slideUp() }, 500) } if (window.location.href.includes("m.baidu.com/")) { setInterval(function () { $('.ec_ad_results').hide() }, 500) } if (typeof jQuery != "undefined") { console.log("ok") } else { var script = document.createElement("script"); script.type = "text/javascript"; script.src = "https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"; document.getElementsByTagName('head')[0].appendChild(script); } var killads = function () { $('*').each(function (index, DOMe) { var src = $(DOMe).attr("src") if (typeof src != "undefined") { for (var i = 0; i < ads.length; i++) { if (src.includes(ads[i])) { $(DOMe).hide() break } } } }) } window.lys = setInterval(function () { if (typeof jQuery != "undefined") { killads(); clearInterval(lys) return } }, 500) })();