-
Notifications
You must be signed in to change notification settings - Fork 0
/
unfollow.js
48 lines (37 loc) · 1.29 KB
/
unfollow.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
let removed = 0;
makeButton();
function makeButton() {
const but = document.createElement("button");
but.style["position"] = "fixed";
but.style["top"] = "15px";
but.style["right"] = "15px";
but.style["background-color"] = "white";
but.style["color"] = "black";
but.style["border-radius"] = "3px";
but.style["border"] = "1px solid gray";
but.style["padding"] = "4px";
but.textContent = "Unfollow All"
but.onclick = () => {
unfollow();
}
document.body.appendChild(but);
}
function unfollow() {
let divs = Array.from(document.getElementsByTagName("div"));
let targets = divs.filter((b) => b.role === "button" && b.dataset.testid && b.dataset.testid.includes("unfollow"));
if (targets.length === 0) {
console.log(`Completed! ${removed} removed!`);
return;
}
for (let target of targets) {
target.click();
}
divs = Array.from(document.getElementsByTagName("div"));
targets = divs.filter((b) => b.role === "button" && b.dataset.testid && b.dataset.testid === "confirmationSheetConfirm")
for (let target of targets) {
target.click();
removed += 1;
}
window.scrollBy(window.innerHeight * 2, 0);
setTimeout(unfollow, 1000);
}