-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove-advertising-script.user.js
94 lines (92 loc) · 3.4 KB
/
remove-advertising-script.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// ==UserScript==
// @name 移除广告
// @name:CN:zh 移除广告
// @namespace https://github.com/GuoChen-thlg
// @version 0.1.4
// @description 移除网页中的广告
// @homepage https://greasyfork.org/zh-CN/users/750817-thlg
// @author THLG
// @supportURL [email protected]
// @updateURL https://github.com/GuoChen-thlg/grease-monkey-script/raw/master/remove-advertising-script.user.js
// @installURL https://github.com/GuoChen-thlg/grease-monkey-script/raw/master/remove-advertising-script.user.js
// @downloadURL https://github.com/GuoChen-thlg/grease-monkey-script/raw/master/remove-advertising-script.user.js
// @contributionURL https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CK755FJ9PSBZ8
// @contributionAmount 1
// @require https://code.jquery.com/jquery-2.1.4.min.js
// @match *://*.baidu.com/*
// @match *://*.csdn.net/*
// @match *://csdn.net/*
// @match *://segmentfault.com/*
// @match *://*.iqiyi.com/*
// @grant none
// @run-at document-end
// ==/UserScript==
(function ($) {
'use strict';
jQuery.noConflict(true);
function clearEl (c_select, p_select) {
if (p_select) {
$(c_select.join(',')).closest(p_select.join(',')).each((i, el) => {
if (el) { el.remove() }
})
} else {
$(c_select.join(',')).remove()
}
}
function clearAds () {
if (/\w{4,5}:\/\/(www\.)?baidu.com\/s.*/.test(location.href)) {
clearEl([
"[cmatchid] [class*=tuiguang]",
".result [class*=tuiguang]",
"[data-click] [data-tuiguang]",
], [
"[cmatchid]",
".result",
"[data-click]",
])
}
if (/\w{4,5}:\/\/jingyan.baidu.com\/s.*/.test(location.href)) {
clearEl([
"#task-panel-wrap",
"#fresh-share-exp-e"
])
}
if (/\w{4,5}:\/\/wenku.baidu.com\/s.*/.test(location.href)) {
clearEl([
"[id*=bdfs] [href*='e.baidu.com']",
], [
"[id*=bdfs]",
])
}
if (/\w{4,5}:\/\/zhidao.baidu.com\/.*/.test(location.href)) {
clearEl([
".list-header [class*='ec-tuiguang']",
], [
".list-header",
])
}
if (/\w{4,5}:\/\/.*csdn.net\/.*/.test(location.href)) {
clearEl([
"ins.adsbygoogle",
"[id*='-ad'] iframe",
])
}
if (/\w{4,5}:\/\/.*segmentfault.*/.test(location.href)) {
clearEl([
"[class*='ad-']",
])
}
if (/\w{4,5}:\/\/.*iqiyi\.com.*/.test(location.href)) {
clearEl([
"[adid]"
])
if ($('.bottom-public').is(':visible') && $('.bottom-public a.skippable-after') && $('.bottom-public a.skippable-after').length > 0) {
$('.bottom-public a.skippable-after')[0]['click']();
}
if ($('.cupid-pause-max-close-btn').length > 0) {
$('.cupid-pause-max-close-btn')[0]['click']();
}
}
}
setInterval(clearAds, 20)
})(jQuery);