-
Notifications
You must be signed in to change notification settings - Fork 6
/
tiktok.js
69 lines (51 loc) · 1.21 KB
/
tiktok.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
function do_tiktok_like(){
state = _STATE_WAIT_TO_CLOSE;
wait_time = 6;
// engagement-icon-v23
var div = document.querySelectorAll('div.engagement-icon-v23');
if((!div) || (div.length < 1)){
div = document.querySelectorAll('span[data-e2e="like-icon"');
}
if ((div) && (div.length > 0)){
console.log("Clicked !");
//div[0].click();
click(div[0]);
return true;
}
return false;
}
function do_tiktok_follow(){
state = _STATE_WAIT_TO_CLOSE;
wait_time = 6;
var btns = document.getElementsByTagName("button");
if(!btns) { return false; }
if(btns.length < 1) { return false; }
//btns[0].click();
for(var i=0; i<btns.length; i++){
if(btns[i].textContent == "Follow") {
//btns[i].click();
click(btns[i]);
return true;
}
}
}
var tiktok_done = false;
function do_tiktok(){
// wait for 5 seconds
if(tick_count < 2) { return; }
if(tick_count > _TIMEOUT_IN_SECS) {
// timeout
window.close();
}
if(tiktok_done) { return; }
tiktok_done = true;
console.log("config.actionType = "+config.actionType);
if (config.actionType === _ACTION_TYPE_TIKTOK_LIKE) {
do_tiktok_like();
return;
}
if (config.actionType === _ACTION_TYPE_TIKTOK_FOLLOW) {
do_tiktok_follow();
return;
}
}