Greasy Fork is available in English.
百度去广告(首页、搜索结果)
当前为
// ==UserScript==
// @name 百度去广告
// @namespace http://tampermonkey.net/
// @version 5.03.1511
// @description 百度去广告(首页、搜索结果)
// @author lidonghui
// @match *://www.baidu.com/*
// @grant none
// ==/UserScript==
(function () {
'use strict';
// 获取当前地址url
var url = location.href;
// 正则匹配博客部分
var baidusearch = /www.baidu.com/i;
if (baidusearch.test(url)) {
function clearAD() {
// 搜索结果推广广告
$(".ec_tuiguang_ppouter").parents().map(function () {
var thisid = $(this).attr("id");
var id = new RegExp('300');
if (thisid != undefined && thisid != "undefined") {
if (id.test(thisid)) {
$("#" + thisid).remove();
}
}
});
// 百度推广广告
$(".c-abstract").parents().map(function () {
var thisid1 = $(this).attr("id");
var id1 = new RegExp('400');
var id2 = new RegExp('500');
if (thisid1 != undefined && thisid1 != "undefined") {
if (id1.test(thisid1) || id2.test(thisid1)) {
$("#" + thisid1).remove();
}
}
});
// 列表广告
$(".m").map(function () {
if ($(this).text() == "广告") {
$(this).parent().parent().remove();
}
});
// 列表广告
$("span").map(function () {
if ($(this).text() == "广告") {
$(this).parent().parent().remove();
}
});
// 首页右边广告
$(".ad-block").parent().parent().parent().remove();
if($("#content_right").children("div").get(0)!=undefined && $("#content_right").children("div").get(0)!="undefined"){
$($("#content_right").children("div").get(0)).remove();
}
}
// 启动定时器
setInterval(function () {
clearAD();
}, 1000);
}
})();