-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontentScript.js
78 lines (62 loc) · 2.33 KB
/
contentScript.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
(() => {
let onProcess = false;
const antidote = (arrObj) => {
setTimeout(() => {
for (let i = 0; i < arrObj.length; i++) {
setTimeout(() => {
arrObj[i].click();
}, 1000 * (i + 1));
}
setTimeout(() => {
// Find Delete (x) button
const spans = document.querySelectorAll(
"span[data-bloks-name='bk.components.TextSpan']"
);
// Click Delete (x) button
spans[spans.length - 1].click();
}, 1000 * (arrObj.length + 5));
setTimeout(() => {
// Find delete confirmation button
const buttons = document.querySelectorAll("button._a9--._a9_1");
// Delete confirmation
buttons[0].click();
}, 1000 * (arrObj.length + 6));
setTimeout(() => {
onProcess = false;
}, 1000 * (arrObj.length + 9));
}, 200);
};
chrome.runtime.onMessage.addListener((obj, sender, response) => {
const { type } = obj;
if (type === "ANTIDOTE") {
let selectModeButton = document.querySelector(
"div._aacl._aaco._aacw._aad0._aad6"
);
let arrObj = [];
let somethingWrongAlert = null;
let somethingWrongButton = null;
setInterval(() => {
somethingWrongAlert = document.querySelector("div._a9-v");
if (somethingWrongAlert !== null) {
setTimeout(() => {
somethingWrongButton =
document.querySelector("button._a9--._a9_1");
somethingWrongButton.click();
}, 800);
}
if (!onProcess) {
selectModeButton.click();
}
setTimeout(() => {
arrObj = document.querySelectorAll(
".wbloks_1 [data-bloks-name='ig.components.Icon']"
);
if (arrObj.length > 0 && !onProcess) {
onProcess = true;
antidote(arrObj);
}
}, 800);
}, 1000);
}
});
})();