-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
100 lines (84 loc) · 2.46 KB
/
Copy pathscript.js
File metadata and controls
100 lines (84 loc) · 2.46 KB
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
$( document ).ready(function() {
console.log( "ready!" );
});
function returnObj(a) {
b = [];
for (i=0;i<a.length;i++){
if ($(a[i]).isVisible()){
c = [];
c[0] = a[i];
if (a[i].tabIndex == '0'){
b.push(a[i]);
}
// b.push(a[i]);
}
}
return b;
};
$.fn.isVisible = function() {
var rect = this[0].getBoundingClientRect();
return (
(rect.height > 0 || rect.width > 0) &&
rect.bottom >= 0 &&
rect.right >= 0 &&
rect.top <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.left <= (window.innerWidth || document.documentElement.clientWidth)
);
};
var reactions = [];
var spanlist = [];
var btns = [];
var z = [];
function onPageLoaded(){
console.log("injecting custom css class");
$("<style type='text/css'> .selected { border-color:#3b5998 !important; border-width:thick !important} </style>").appendTo("head");
// $("<div/>").addClass("selected").text("SOME NEW TEXT").appendTo("body");
}
function showSelected(){
visible_count = 0;
y = returnObj($('._4-u2.mbm._4mrt._5v3q._4-u8'));
// $(y).removeClass("selected");
$(y[1]).addClass("selected");
try {
$(y[0]).removeClass("selected");
$(y[2]).removeClass("selected");
} catch(err) {
console.log("Error when catching post index");
}
return visible_count;
}
function clickReaction(reaction){
let likeBtn = $("div._5jmm._5pat[tabindex='0']:visible")
.find('a._6a-y._3l2t._18vj[role="button"]')
// let likeBtn = $("div._5jmm._5pat._3lb4[tabindex='0']:visible")
// .find('.UFILikeLink._4x9-._4x9_:visible')
let reactKey = Object.keys(likeBtn['0'])[0]
likeBtn[0][reactKey].pendingProps.onMouseEnter()
setTimeout(() => {
let reactionsMenu = $('._iu-._628b._1ef3:visible')
let reactions = $(reactionsMenu[reactionsMenu.length-1]).children()
let ri
// finally clicks
if (reaction == "curtir"){
ri = 0;
} else if (reaction == "amei"){
ri = 1;
} else if (reaction == "haha"){
ri = 2;
} else if (reaction == "uau"){
ri = 3;
} else if (reaction == "triste"){
ri = 4;
} else if (reaction == "grr"){
ri = 5;
} else {
console.log("Invalid reaction");
}
console.log("Clicking on the reaction "+reaction );
console.log(reactions, ri)
reactions[ri].click()
setTimeout(() => {
likeBtn[0][reactKey].pendingProps.onMouseLeave()
}, 200)
}, 800)
}