diff --git a/baidu/clearAd.user.js b/baidu/clearAd.user.js index aa04e13..cbf6cab 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.5 +// @version 0.0.6 // @description 去除百度上下推广广告 // @author MiaoWoo // @include http*://*.baidu.* @@ -21,7 +21,7 @@ var count = 0; function showCount(cn){ if(cn>0){ - count+=cn; + count += cn; var content_right = document.querySelector('#content_right'); if(content_right){ content_right.style.position = 'relative'; @@ -42,31 +42,39 @@ margin-bottom:30px; } } function clear() { + tempCount = 0 selectors.forEach(function(selector) { var doms = document.querySelectorAll(selector); if(doms.length){ doms = Array.from(doms); - showCount(doms.length); + tempCount += doms.length; doms.forEach(function(dom) { dom.parentNode.removeChild(dom); }); } }); - ['.m', 'a span'].forEach(function (c) { + var adKeyword = ['广告', '评价'] + var classKeyWord = ['.m', 'a span'] + classKeyWord.forEach(function (c) { var result = $(c) - var tempCount = 0 result.each(function (index,element) { - if($(element).html() == "广告" && $(element).parent().parent().css('display')!='none'){ - $(element).parent().parent().remove(); - tempCount++ - } - if($(element).html() == "评价" && $(element).parent().parent().parent().css('display')!='none'){ + if(adKeyword.indexOf($(element).text())){ $(element).parent().parent().remove(); tempCount++ } }); - showCount(tempCount); }) + $('.ad-block').each(function (index,element) { + $(element).parent().parent().parent().remove(); + tempCount++ + }) + $('div a').each(function (index, element) { + if($(element).text()=="广告"){ + $(element).parent().parent().parent().parent().parent().parent().parent().remove() + } + tempCount++ + }) + showCount(tempCount); } setInterval(clear, 500); })(); \ No newline at end of file