-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguardian.js
50 lines (45 loc) · 1.26 KB
/
guardian.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
// ==UserScript==
// @author dylanarmstrong
// @description guardian register stuff
// @grant none
// @match https://www.theguardian.com/*
// @name guardian
// @namespace https://github.com/dylanarmstrong/userscripts/
// @run-at document-start
// @supportURL https://github.com/dylanarmstrong/userscripts/issues
// @updateURL https://raw.githubusercontent.com/dylanarmstrong/userscripts/main/guardian.js
// @version 2
// ==/UserScript==
/**
* Naive fix for theguardian, doesn't work yet.
*/
(function main() {
const loop = (selectors, root) => {
for (const selector of selectors) {
for (const evil of root.querySelectorAll(selector)) evil.remove();
}
};
const destroy = () => {
loop(['iframe', 'script'], document.head);
const body = document.body.cloneNode(true);
document.body.innerHTML = '';
body.id = 'destroyed';
loop(
[
'style[type="text/css"]',
'iframe',
'script',
'#sign-in-gate',
'.contributions__adblock',
'.top-banner-ad-container.js-top-banner',
'.ad-slot',
'.adBlock',
'[id^=sp_message_container]',
],
body,
);
document.body = body;
};
destroy();
setTimeout(destroy, 1000);
})();