-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfilter.js
62 lines (46 loc) · 1.63 KB
/
filter.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
var stream = document.querySelector("#globalContainer");
var working = false;
function filter(){
if(localStorage.getItem("disabled"))
return;
var stories = stream.querySelectorAll(".userContentWrapper");
working = true;
for(var i=0; i < stories.length; i++){
var story = stories[i];
var content = story.textContent;
if(!story.classList.contains("brotherdone") && /דיירים|אח הגדול/.test(content)){
toggle(story, false);
var more = document.createElement("A");
more.innerHTML = "אני רוצה לראות זבל";
more.style.fontSize = "9px";
var brother = document.createElement("div");
brother.classList.add("antibrother");
brother.innerHTML = "<h1 style='line-height: 80px; display: inline-block; margin: 0 10px;'>פח</h1>";
brother.appendChild(more);
story.appendChild(brother);
attach(more, story);
story.classList.add("brotherdone")
}
}
working = false;
}
function attach(button, element){
button.addEventListener("click", function(){
toggle(element, true);
});
}
function toggle(element, isShow){
var children = element.childNodes;
for(var z=0; z<children.length; z++)
children[z].style.display = (isShow)? "block" : "none";
var button = element.querySelector(".antibrother");
if(button)
button.style.display = (isShow)? "none" : "block";
}
if(stream){
filter();
stream.addEventListener("DOMNodeInserted", function (ev) {
if(!working)
filter();
}, false);
}