-
Notifications
You must be signed in to change notification settings - Fork 1
/
content.js
143 lines (119 loc) · 3.73 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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
var clicks = 10;
var userName = "Nico Jhony";
var likeUser = false;
var scrollInterval, clickInterval;
var links = {
init: function() {
this.cacheDom();
this.bindEvents();
},
cacheDom: function() {
this.$mainContainer = $('#contentArea');
this.$links = this.$mainContainer.find(".UFILikeLink");
this.$scrollElements = $("html, body");
},
bindEvents: function() {
var self = this;
// call every 10 seconds Much Wow
// clickInterval = setInterval(function() {
// var links = self.$mainContainer.find(".UFILikeLink");
// self.postLike(links);
// }, 3000);
// scrollInterval = setInterval(function() {
// self.scrollTimeline(self.$scrollElements);
// }, 10000);
clickInterval = setInterval(function() {
var users = $(".fbUserContent");
self.followerLike(".UFICommentActions", userName, users );
}, 5000);
},
postLike: function(links) {
this.clickLike(links, ".UFICommentActions" );
},
followerLike: function(targetDiv, userName, users){
var _ = this;
// Initial time delay
time = 1000;
users.each(function() {
var self = this;
$(self).each(function(s) {
if ($(this).find(".fwb").find("a")[0].innerHTML == userName) {
// console.log(this);
if ($(this).find(".UFILikeLink")[0].attributes[0].value == "false") {
// console.log("adadadadada");
// $(this).closest(users).find(".UFILikeLink")[0].click();
var that = this;
console.log($(that).find(".UFILikeLink")[0]);
setTimeout(function () {
$(that).find(".UFILikeLink")[0].click();
}, time);
}
}
// add 1 sec delay between iterations
time +=1000;
})
});
},
clickLike: function(links, targetDiv){
var _ = this;
// Initial time delay
time = 1000;
links.each(function() {
var self = this;
$(self).each(function(s) {
if ($(this)[0].attributes[0].value == "false") {
if(self.closest(targetDiv) == null){
console.log(time);
setTimeout(function () {
if(clicks > 0) {
self.click();
clicks --;
console.log("click");
// setLikesNumber(clicks);
}
else {
// Clear scroll Timeout when the click goes to zero
_.clearTime(scrollInterval);
_.clearTime(clickInterval);
}
}, time);
}
}
// add 1 sec delay between iterations
time +=1000;
})
});
},
// Implement AutoScroll
scrollTimeline: function(elem){
// scrollInterval = setInterval(function(){
elem.animate({scrollTop: $(document).height()}, 4000);
// }, 10000);
},
clearTime: function(interval) {
clearInterval(interval);
}
}
links.init();
$(document).ready(function(){
$("#contentArea").hover(setFilters, isEnabled);
});
function setFilters(){
chrome.extension.sendRequest({'action' : 'get_filters'},
function(response) {
console.log(response);
});
}
function setLikesNumber(likes) {
console.log(likes);
chrome.extension.sendRequest({'action': 'update_popup', currentLikes : likes},
function(response) {
console.log(response);
});
}
function isEnabled(){
chrome.extension.sendRequest({'action':'is_enabled'},
function(response) {
console.log(response);
})
}