Skip to content

Commit 2a76a33

Browse files
committed
Update Kill Baidu AD.user.js
1 parent 368bc42 commit 2a76a33

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Kill Baidu AD/Kill Baidu AD.user.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// @name:zh-TW 百度廣告(首尾推廣及右側廣告)清理
55
// @name:en Kill Baidu AD
66
// @namespace hoothin
7-
// @version 1.23.11
7+
// @version 1.23.12
88
// @description 彻底清理百度搜索(www.baidu.com)结果首尾的推广广告、二次顽固广告、右侧广告,去除重定向,删除百家号
99
// @description:zh-CN 彻底清理百度搜索(www.baidu.com)结果首尾的推广广告、二次顽固广告、右侧广告,去除重定向,移除百家号
1010
// @description:zh-TW 徹底清理百度搜索(www.baidu.com)結果首尾的推廣廣告、二次頑固廣告、右側廣告,去除重定向,刪除百家號
@@ -31,7 +31,11 @@
3131

3232
(function() {
3333
'use strict';
34-
var MO = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, killBaijiaType = 1, killRight, killRightStyle, killRightRegister, hidePicture, hidePictureStyle, hidePictureRegister, blackList;
34+
var MO = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, killBaijiaType = 1, killRight, killRightStyle, killRightRegister, hidePicture, keepBaijia, hidePictureStyle, hidePictureRegister, blackList;
35+
killRight = !!GM_getValue("killRight");
36+
hidePicture = !!GM_getValue("hidePicture");
37+
keepBaijia = !!GM_getValue("keepBaijia");
38+
blackList = GM_getValue("blackList") || [];
3539
if (MO) {
3640
var observer = new MO(function(records) {
3741
records.map(function(record) {
@@ -93,7 +97,7 @@
9397
}
9498
if (!mu || mu === 'null') return;
9599
if (/^https:\/\/baijiahao\.baidu\.com/.test(mu)) {
96-
item.remove();
100+
!keepBaijia && item.remove();
97101
return;
98102
} else {
99103
let title = item.querySelector('[data-module="title"]');
@@ -109,7 +113,7 @@
109113
let mu = item.getAttribute("mu");
110114
if (mu && mu !== 'null' && mu.indexOf("http") == 0 && mu.indexOf("nourl") == -1 && item.getAttribute("tpl") != "short_video") {
111115
if (/^https:\/\/baijiahao\.baidu\.com/.test(mu)) {
112-
item.remove();
116+
!keepBaijia && item.remove();
113117
return;
114118
} else {
115119
let title = item.querySelector('h3');
@@ -147,7 +151,7 @@
147151
[].forEach.call(item.querySelectorAll("a>div>span+img"), function(img) {
148152
if (img && /^https?:\/\/pic\.rmb\.bdstatic\.com/.test(img.src)) {
149153
//checkBaijia(item);
150-
item.remove();
154+
!keepBaijia && item.remove();
151155
}
152156
});
153157
}
@@ -453,9 +457,6 @@
453457

454458
function run() {
455459
try {
456-
killRight = !!GM_getValue("killRight");
457-
hidePicture = !!GM_getValue("hidePicture");
458-
blackList = GM_getValue("blackList") || [];
459460
if (location.host === "greasyfork.org") {
460461
function initConfig() {
461462
let parent = document.querySelector('#additional-info');
@@ -480,6 +481,7 @@
480481
};
481482
let hidePictureInput = createCheckbox('隐藏图片并简化样式', hidePicture);
482483
let killRightInput = createCheckbox('隐藏右边栏并多列显示', killRight);
484+
let keepBaijiaInput = createCheckbox('保留百家号', keepBaijia);
483485
let importInput = document.createElement('textarea');
484486
importInput.placeholder = '订阅 uBlacklist 规则:如 https://git.io/ublacklist';
485487
importInput.style.width = '100%';
@@ -504,8 +506,10 @@
504506
saveBtn.addEventListener("click", function(e) {
505507
hidePicture = hidePictureInput.checked;
506508
killRight = killRightInput.checked;
509+
keepBaijia = keepBaijiaInput.checked;
507510
GM_setValue("hidePicture", hidePicture);
508511
GM_setValue("killRight", killRight);
512+
GM_setValue("keepBaijia", keepBaijia);
509513
if (importInput.value) {
510514
alert("读取规则中……");
511515
let importUrls = importInput.value.trim().split("\n");

0 commit comments

Comments
 (0)