-
Notifications
You must be signed in to change notification settings - Fork 0
/
guardian.js
52 lines (47 loc) · 1.29 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
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/master/guardian.js
// @version 1
// ==/UserScript==
/**
* Naive fix for theguardian, doesn't work yet.
*/
(function() {
'use strict';
const loop = (selectors, root) => {
for (const selector of selectors) {
Array.from(root.querySelectorAll(selector))
.forEach((evil) => evil.parentNode.removeChild(evil));
}
};
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);
})();