Greasy Fork is available in English.
去掉百度的推广链接
当前为
// ==UserScript==
// @name AC-百度去广告
// @namespace ACNoAdd
// @description 去掉百度的推广链接
// @include http://www.baidu.com/*
// @include https://www.baidu.com/*
// @version 3.0
// @grant none
// @author AC
// @icon https://coding.net/u/zb227/p/zbImg/git/raw/master/img0/icon.jpg
// @run-at document-end
// ==/UserScript==
mo = new MutationObserver(function(allmutations) {
allmutations.map(function(oneNode){
//if(oneNode.addedNodes[0]){ //如果存在增加的点
// console.log(oneNode);
//}
});
removeAD();
});
var targets = document.body;
mo.observe(targets, {'childList': true,'characterData':true,'subtree': true});
function removeAD(){
var no = document.getElementById("content_right");
if(no != null) no.remove();
var father = document.querySelectorAll("#content_left")[0].childNodes;
var lastId = 0;
for(var i = 0; i < father.length; i++){
if((father[i].outerHTML+"").indexOf("<div") == 0){
if(father[i].className.indexOf("result") != 0){
if(father[i].className == "sp-separator"){
continue;
}
console.log(father[i].className);
father[i].remove();
}
//1.移除重复ID的,或者插入的小ID值广告
//console.log(father[i].id+","+lastId);
if(father[i].id == lastId){
console.log("remove: "+(i-1>=0)?(i-1):0);
father[(i-1>=0)?(i-1):0].remove(); //移除之前保存
} else{
if(lastId - 5 > father[i].id){ //避免小ID广告
console.log("remove: "+father[i].id);
father[i].remove();
} else{
lastId = father[i].id;
}
}
// 2.移除ID>1000的,className不为result...
//if(father[i].id > 1000) {
// father[i].remove();
//}
//if(father[i].id == null || father[i].id == ""){
// console.log(father[i].className);
// 3.移除className长度为6的空ID值
// if(father[i].className.length == 6) father[i].remove();
//}
}
}
}