1
0
Fork 0

更新 'baidu/clearAd.user.js'

master
502647092 2019-01-08 14:43:16 +08:00
parent 0308fd9b81
commit 9366a63bc7
1 changed files with 43 additions and 9 deletions

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name 百度广告去除 // @name 百度广告去除
// @namespace http://ide.yumc.pw/ // @namespace http://ide.yumc.pw/
// @version 0.0.2 // @version 0.0.3
// @description 去除百度上下推广广告 // @description 去除百度上下推广广告
// @author MiaoWoo // @author MiaoWoo
// @include http*://*.baidu.* // @include http*://*.baidu.*
@ -11,15 +11,49 @@
(function() { (function() {
'use strict'; 'use strict';
function clear(){ var selectors = `
var content = document.getElementById('content_left') #content_left [style*="display:block !important;visibility:visible !important"]
var result = content.childNodes; [tpl="right_toplist"]
for (var i = 0; i<result.length;i++){ [class="c-gray c-feedback"]
var c = result[i] [data-click*="vLevel"]
if (c.className != "result c-container "){ `;
content.removeChild(c) selectors = selectors.trim().split('\n');
var count = 0;
function showCount(cn){
if(cn>0){
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','<div id="msg-remove" style="'+style+'"></div>');
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);
})(); })();