forked from AntonOsika/newsfeed-eradicator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
erad2.js
52 lines (44 loc) · 1.61 KB
/
erad2.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
var startLoop = function() {
var stream = false, ticker = false;
var tryRemove = function () {
console.log("remove called");
var divs = document.getElementsByTagName("div"), item;
for (var i = 0, len = divs.length; i < len; i++) {
// If finished,
if (ticker && stream) {
try {
f = document.getElementById("u_0_f").children[0];
home = document.getElementById("u_0_g").children[1];
f.addEventListener("click", function () {console.log("hej")});
home.addEventListener("click", startLoop);
return;
}
catch (err) {
window.setTimeout(tryRemove, 100);
console.log("Setting timer because failure.");
return;
}
}
item = divs[i];
try {
if (!ticker && item.id.match("pagelet_ticker") != null) {
item.remove();
ticker = true;
console.log("ticker removed");
}
else if (!stream && item.id.match("topnews_main_stream") != null) {
item.remove()
stream = true;
console.log("stream " + stream);
}
}
catch (err) {}
}
if (!(stream && sticker)) {
window.setTimeout(tryRemove, 100);
//console.log("Setting timer as usual");
}
}
window.setTimeout(tryRemove, 100);
}
startLoop();