-
Notifications
You must be signed in to change notification settings - Fork 6
/
yt.js
64 lines (49 loc) · 1.13 KB
/
yt.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
function do_yt_like(){
state = _STATE_WAIT_TO_CLOSE;
wait_time = 6;
btn = document.querySelector('button[aria-label^="like"');
if(btn){
btn.click();
} else {
console.log("like button not found !");
}
}
function do_yt_sub(){
state = _STATE_WAIT_TO_CLOSE;
wait_time = 6;
var buttons = document.querySelectorAll('.ytd-subscribe-button-renderer');
if((!buttons) || (buttons.length < 1)){
console.log("No Subscribe button found :()");
return;
}
for(var i=0; i<buttons.length; i++){
var s = buttons[i].textContent;
if (s==='Subscribe'){
buttons[i].click();
break;
}
}
}
var youtube_done = false;
function do_youtube(){
// wait for 5 seconds
if(tick_count < 2) { return; }
if(tick_count > _TIMEOUT_IN_SECS) {
// timeout
window.close();
}
if(youtube_done) { return; }
youtube_done = true;
console.log("youtube_done");
console.log("config.actionType = "+config.actionType);
if (config.actionType === _ACTION_TYPE_YT_SUB) {
console.log("do_yt_sub");
do_yt_sub();
return;
}
if (config.actionType === _ACTION_TYPE_YT_LIKE) {
console.log("do_yt_like");
do_yt_like();
return;
}
}