-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhide.js
More file actions
53 lines (47 loc) · 1.49 KB
/
hide.js
File metadata and controls
53 lines (47 loc) · 1.49 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
53
//keywords to block on web
kw = ['','',''] // keywords to be inserted in the [],(which will be blocked)
tags = "SPANEMBIULOLI";
total = 0;
//parsing to the opened page one by one
//has a function defined hide which it execuets if keyword is found
for(var ii = 0; ii < kw.length; ii++)
{
o = $(`:contains(${kw[ii]}):not(:has(:contains(${kw[ii]})))`)
for(var i = 0; i < o.length; i++)
{
if (!o[i].parentNode || o[i].parentNode.nodeName === "BODY") {
continue;
}
hide(o[i]);
total++;
}
}
if(total >= 10) {
headings = document.querySelectorAll("h1, h2, h3, h4, h5, h6");
for(var i = 0; i < headings.length; i++) hideNode(headings[i]);
}
//function to block when a keyword and blur's pics found on the page
function hide(node) {
ancestor = node.parentNode;
if(ancestor != null) {
if (ancestor.parentNode != null
&& ancestor.tagName != 'BODY')
ancestor = ancestor.parentNode;
imgs = ancestor.getElementsByTagName('img');
for(var i = 0; i < imgs.length; i++)
imgs[i].style.webkitFilter = "blur(10px)"
lists = ancestor.getElementsByTagName('li');
for(var i = 0; i < lists.length; i++) hideNode(lists[i]);
}
if (node == null || node.parentNode == null) return;
all_child = node.parentNode.children;
for(var i = 0; i < all_child; i++) {
var type = all_child[i].tagName;
if (tags.match(type) != null) hideNode(all_child[i]);
}
hideNode(node);
}
function hideNode(node) {
node.textContent = '[TEXT BLOCKED: OFFENSIVE LANG DETECTED]';
node.style.color = 'red'
}