|
4 | 4 | // @name:zh-TW 百度廣告(首尾推廣及右側廣告)清理 |
5 | 5 | // @name:en Kill Baidu AD |
6 | 6 | // @namespace hoothin |
7 | | -// @version 1.23.11 |
| 7 | +// @version 1.23.12 |
8 | 8 | // @description 彻底清理百度搜索(www.baidu.com)结果首尾的推广广告、二次顽固广告、右侧广告,去除重定向,删除百家号 |
9 | 9 | // @description:zh-CN 彻底清理百度搜索(www.baidu.com)结果首尾的推广广告、二次顽固广告、右侧广告,去除重定向,移除百家号 |
10 | 10 | // @description:zh-TW 徹底清理百度搜索(www.baidu.com)結果首尾的推廣廣告、二次頑固廣告、右側廣告,去除重定向,刪除百家號 |
|
31 | 31 |
|
32 | 32 | (function() { |
33 | 33 | '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") || []; |
35 | 39 | if (MO) { |
36 | 40 | var observer = new MO(function(records) { |
37 | 41 | records.map(function(record) { |
|
93 | 97 | } |
94 | 98 | if (!mu || mu === 'null') return; |
95 | 99 | if (/^https:\/\/baijiahao\.baidu\.com/.test(mu)) { |
96 | | - item.remove(); |
| 100 | + !keepBaijia && item.remove(); |
97 | 101 | return; |
98 | 102 | } else { |
99 | 103 | let title = item.querySelector('[data-module="title"]'); |
|
109 | 113 | let mu = item.getAttribute("mu"); |
110 | 114 | if (mu && mu !== 'null' && mu.indexOf("http") == 0 && mu.indexOf("nourl") == -1 && item.getAttribute("tpl") != "short_video") { |
111 | 115 | if (/^https:\/\/baijiahao\.baidu\.com/.test(mu)) { |
112 | | - item.remove(); |
| 116 | + !keepBaijia && item.remove(); |
113 | 117 | return; |
114 | 118 | } else { |
115 | 119 | let title = item.querySelector('h3'); |
|
147 | 151 | [].forEach.call(item.querySelectorAll("a>div>span+img"), function(img) { |
148 | 152 | if (img && /^https?:\/\/pic\.rmb\.bdstatic\.com/.test(img.src)) { |
149 | 153 | //checkBaijia(item); |
150 | | - item.remove(); |
| 154 | + !keepBaijia && item.remove(); |
151 | 155 | } |
152 | 156 | }); |
153 | 157 | } |
|
453 | 457 |
|
454 | 458 | function run() { |
455 | 459 | try { |
456 | | - killRight = !!GM_getValue("killRight"); |
457 | | - hidePicture = !!GM_getValue("hidePicture"); |
458 | | - blackList = GM_getValue("blackList") || []; |
459 | 460 | if (location.host === "greasyfork.org") { |
460 | 461 | function initConfig() { |
461 | 462 | let parent = document.querySelector('#additional-info'); |
|
480 | 481 | }; |
481 | 482 | let hidePictureInput = createCheckbox('隐藏图片并简化样式', hidePicture); |
482 | 483 | let killRightInput = createCheckbox('隐藏右边栏并多列显示', killRight); |
| 484 | + let keepBaijiaInput = createCheckbox('保留百家号', keepBaijia); |
483 | 485 | let importInput = document.createElement('textarea'); |
484 | 486 | importInput.placeholder = '订阅 uBlacklist 规则:如 https://git.io/ublacklist'; |
485 | 487 | importInput.style.width = '100%'; |
|
504 | 506 | saveBtn.addEventListener("click", function(e) { |
505 | 507 | hidePicture = hidePictureInput.checked; |
506 | 508 | killRight = killRightInput.checked; |
| 509 | + keepBaijia = keepBaijiaInput.checked; |
507 | 510 | GM_setValue("hidePicture", hidePicture); |
508 | 511 | GM_setValue("killRight", killRight); |
| 512 | + GM_setValue("keepBaijia", keepBaijia); |
509 | 513 | if (importInput.value) { |
510 | 514 | alert("读取规则中……"); |
511 | 515 | let importUrls = importInput.value.trim().split("\n"); |
|
0 commit comments