-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
71 lines (65 loc) · 3.14 KB
/
popup.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
function invPage(){
document.querySelector('#clickEvent').disabled = true;
document.querySelector('#click').disabled = true;
document.querySelector('#load').style.display = 'block';
var myCustomCode = "var x = document.getElementsByClassName('uiButton _1sm');"+
"var count = 0;"+
"for(var i=0;i<x.length;i++){"+
"x[i].click();"+
"count++;"+
"}"+
"count;";
var outputLog = document.querySelector('#outputLog');
outputLog.value = "Please wait, it may take a while!";
chrome.tabs.getSelected(null, function(tab){
chrome.tabs.executeScript(tab.id, {code: myCustomCode}, function(rez){
if(rez==0){
outputLog.value = "There are no more friends to invite.\nMake you sure that you are on right page.";
document.querySelector('#clickEvent').disabled = false;
document.querySelector('#click').disabled = false;
document.querySelector('#load').style.display = 'none';
} else {
outputLog.value = rez+" friends invited successfully!";
document.querySelector('#clickEvent').disabled = false;
document.querySelector('#click').disabled = false;
document.querySelector('#load').style.display = 'none';
}
});
});
}
function invEve(){
document.querySelector('#clickEvent').disabled = true;
document.querySelector('#click').disabled = true;
document.querySelector('#load').style.display = 'block';
var myCustomCode = "var x = document.getElementsByClassName('_1pu2');"+
"var count = 0;"+
"for(var i=0;i<x.length;i++){"+
"x[i].click();"+
"count++;"+
"}"+
"count;";
var outputLog = document.querySelector('#outputLog');
outputLog.value = "Please wait, it may take a while!";
chrome.tabs.getSelected(null, function(tab){
chrome.tabs.executeScript(tab.id, {code: myCustomCode}, function(rez){
if(rez==0){
outputLog.value = "There are no more friends to invite.\nMake you sure that you are on right page.";
document.querySelector('#clickEvent').disabled = false;
document.querySelector('#click').disabled = false;
document.querySelector('#load').style.display = 'none';
} else {
outputLog.value = rez+" friends invited successfully!";
document.querySelector('#clickEvent').disabled = false;
document.querySelector('#click').disabled = false;
document.querySelector('#load').style.display = 'none';
}
});
});
}
function init() {
clicker = document.querySelector('#click');
clickerEvent = document.querySelector('#clickEvent');
clicker.addEventListener('click', invPage, false);
clickerEvent.addEventListener('click', invEve, false);
}
document.addEventListener('DOMContentLoaded', init);