-
Notifications
You must be signed in to change notification settings - Fork 0
/
fb.js
112 lines (88 loc) · 2.6 KB
/
fb.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
function do_fb_like(){
state = _STATE_WAIT_TO_CLOSE;
wait_time = 10 - Math.floor(Math.random() * 5);
chrome.storage.local.get('speedTempo', function (result) {
if (result.speedTempo) {
if (result.speedTempo == 'slow') {
wait_time = 15 - Math.floor(Math.random() * 10);
}
if (result.speedTempo == 'normal') {
wait_time = 10 - Math.floor(Math.random() * 5);
}
if (result.speedTempo == 'fast') {
wait_time = 3 - Math.floor(Math.random() * 3);
}
}
})
var section = document.querySelector('div[role="main"]>div');
if(!section) { console.log("section not found !"); return; }
//if(section.querySelector("div._5u9t")) { console.log("already liked"); return; }
var s = "";
var div = section.querySelectorAll('[aria-label="Like"]');
if(div.length==0) {
div = section.querySelectorAll('[aria-label="Follow"]')
console.log('nasao follow');
}
for(var i=0; i<div.length; i++){
s = div[i].textContent;
if(s === "Like" || s=== "Follow"){
// check for class 'div._5u9t' di parent
var b = false;
var dv = div[i].parentElement;
while ((dv) && (dv !== section)) {
if(dv.className.indexOf("_5u9t") !== -1){
b = true;
break;
}
dv = dv.parentElement;
}
if(!b) { div[i].click(); } else { console.log("already liked!"); }
return;
}
}
}
function do_fb_post_like(){
state = _STATE_WAIT_TO_CLOSE;
wait_time = 10 - Math.floor(Math.random() * 5);
chrome.storage.local.get('speedTempo', function (result) {
if (result.speedTempo) {
if (result.speedTempo == 'slow') {
wait_time = 15 - Math.floor(Math.random() * 10);
}
if (result.speedTempo == 'normal') {
wait_time = 10 - Math.floor(Math.random() * 5);
}
if (result.speedTempo == 'fast') {
wait_time = 3 - Math.floor(Math.random() * 3);
}
}
})
var div = document.querySelector('div[aria-label="Remove Like"]');
if(div) { return; }
var div = document.querySelector('[data-sigil="touchable ufi-inline-like like-reaction-flyout"],[aria-label="Like"]');
if(!div) { return; }
div.click();
}
var facebook_done = false;
function do_facebook(){
// wait for 5 seconds
if(tick_count < 2) { return; }
if(tick_count > _TIMEOUT_IN_SECS) {
// timeout
window.close();
}
if(facebook_done) { return; }
facebook_done = true;
console.log("do_facebook");
console.log("config.actionType = "+config.actionType);
if (config.actionType === _ACTION_TYPE_FACEBOOK_POST_LIKE) {
console.log("do_fb_post_like");
do_fb_post_like();
return;
}
if (config.actionType === _ACTION_TYPE_FACEBOOK_LIKE) {
console.log("do_fb_like");
do_fb_like();
return;
}
}