diff --git a/baidu/clearAd.user.js b/baidu/clearAd.user.js index 73c08af..280a3cf 100644 --- a/baidu/clearAd.user.js +++ b/baidu/clearAd.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name 百度广告去除 // @namespace http://ide.yumc.pw/ -// @version 0.0.2 +// @version 0.0.3 // @description 去除百度上下推广广告 // @author MiaoWoo // @include http*://*.baidu.* @@ -11,15 +11,49 @@ (function() { 'use strict'; - function clear(){ - var content = document.getElementById('content_left') - var result = content.childNodes; - for (var i = 0; i0){ + count+=cn; + var content_right = document.querySelector('#content_right'); + if(content_right){ + content_right.style.position = 'relative'; + var style = ` +line-height: 42px; +text-align: center; +background: #0c0; +color: #fff; +margin-bottom:30px; +`; + var msgCount = document.querySelector('#msg-remove'); + if(!msgCount){ + content_right.insertAdjacentHTML('afterbegin','
'); + msgCount = document.querySelector('#msg-remove'); + } + msgCount.innerHTML = '已过滤:'+count+'条垃圾广告,本次过滤:'+cn+'条'; } } } - setTimeout(clear, 300) + function clear() { + selectors.forEach(function(selector) { + var doms = document.querySelectorAll(selector); + if(doms.length){ + doms = Array.from(doms); + showCount(doms.length); + doms.forEach(function(dom) { + dom.parentNode.removeChild(dom); + }); + } + }); + } + setInterval(function () { + clear(); + },500); })(); \ No newline at end of file