Skip to content

Commit e0b50f1

Browse files
committed
new script
1 parent 9f986c5 commit e0b50f1

File tree

2 files changed

+235
-178
lines changed

2 files changed

+235
-178
lines changed

scripts/backup/auto-like-fb.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
javascript: (async function () {
2+
function sleep(ms) {
3+
return new Promise((resolve) => setTimeout(resolve, ms));
4+
}
5+
function focusTo(element) {
6+
element.dispatchEvent(
7+
new MouseEvent("pointerover", {
8+
view: window,
9+
bubbles: true,
10+
cancelable: true,
11+
})
12+
);
13+
}
14+
15+
function scrollToBottom() {
16+
window.scrollTo(0, document.body.scrollHeight, { behavior: "smooth" });
17+
}
18+
19+
const doneKey = "auto-like-done";
20+
const btns = [];
21+
while (true) {
22+
if (!btns.length) {
23+
let curBtns = Array.from(
24+
document.querySelectorAll("[aria-label='Bày tỏ cảm xúc']:not(li *)")
25+
);
26+
let added = 0;
27+
for (let btn of curBtns) {
28+
if (btn.getAttribute(doneKey) === null) {
29+
btns.push(btn);
30+
btn.setAttribute(doneKey, true);
31+
added++;
32+
}
33+
}
34+
if (added === 0) break;
35+
}
36+
37+
for (let btn of btns) {
38+
btn.scrollIntoView({
39+
block: "center",
40+
behavior: "smooth",
41+
});
42+
btn.click();
43+
await sleep(500);
44+
let loveBtn = document.querySelector("[aria-label='Yêu thích']");
45+
if (loveBtn) {
46+
focusTo(loveBtn);
47+
await sleep(500);
48+
loveBtn.click();
49+
await sleep(500);
50+
}
51+
btns.splice(btns.indexOf(btn), 1);
52+
}
53+
scrollToBottom();
54+
await sleep(1000);
55+
}
56+
alert("xong");
57+
})();

0 commit comments

Comments
 (0)