-
Notifications
You must be signed in to change notification settings - Fork 2
/
content.js
71 lines (54 loc) · 1.56 KB
/
content.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
63
64
65
setInterval(function(){
if (document.activeElement.name == "add_comment_text_text"){
document.activeElement.addEventListener('keydown', commentFunction);
}
}, 500);
var commentFunction = function(e){
var e = window.event||e;
var key = e.keyCode ? e.keyCode : e.which;
if (key === 13 && isOffensive(document.activeElement.value) && !window.confirm("Are you sure you want to comment this?")){
e.preventDefault()
e.stopPropagation();
return false;
}
}
var clickedPost = function()
{
console.log(event);
if (isOffensive(document.querySelectorAll('input[name="xhpc_message"]')[0].value)){
var r = window.confirm("Are you sure you want to post this?");
if( !r )
event.preventDefault();
}
}
setInterval(function() {
//from the home page
element = document.querySelectorAll('button[value="1"][type="submit"]')[0]
parent = element.parentNode
element.addEventListener('click', clickedPost)
//from profile page
element2 = document.querySelectorAll('button[value="1"][type="submit"]')[2]
parent2 = element2.parentNode
element2.addEventListener('click', clickedPost)
}, 500);
var isOffensive = function(comment){
var bad = new Array();
bad[0] = /\w*fuck\w*/
bad[1] = /\w*fck\w*/
bad[2] = /\w*fuk\w*/
bad[3] = /\w*shit\w*/
bad[4] = /\w*penis\w*/
bad[5] = /\w*fag\w*/
bad[6] = /\w*ass\w*/
bad[7] = /\w*nigger\w*/
bad[8] = /\w*dick\w*/
bad[9] = /\w*cunt\w*/
bad[10] = /\w*kill\s*yourself\w*/
bad[11] = /\w*slut\w*/
bad[12] = /\w*whore\w*/
for (var i = bad.length - 1; i >= 0; i--) {
if (bad[i].test(comment))
return true;
};
return false;
}