-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguardian.js
More file actions
52 lines (47 loc) · 1.35 KB
/
guardian.js
File metadata and controls
52 lines (47 loc) · 1.35 KB
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
// ==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",
".ad-slot",
".ad-slot-container",
".adBlock",
".contributions__adblock",
".top-banner-ad-container.js-top-banner",
".top-fronts-banner-ad-container",
"[id^=sp_message_container]",
],
document.body,
);
// document.body = body;
};
destroy();
setTimeout(destroy, 1000);
})();