-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
48 lines (45 loc) · 1.54 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
chrome.storage.local.get(["urls"], (result) => {
const urls = result.urls || [];
if (urls.some((url) => window.location.href.includes(url))) {
const button = document.createElement("button");
button.innerText = "Delete Elements";
button.id = "delete-div-button";
button.style.position = "fixed";
button.style.bottom = "20px";
button.style.right = "20px";
button.style.zIndex = "10000";
button.style.padding = "10px 20px";
button.style.fontSize = "16px";
button.style.color = "#fff";
button.style.backgroundColor = "#007bff";
button.style.border = "none";
button.style.borderRadius = "5px";
button.style.cursor = "pointer";
document.body.appendChild(button);
button.addEventListener("click", () => {
chrome.storage.local.get(["classes"], (result) => {
const classes = result.classes || [];
if (classes.length === 0) {
alert("No class names available!");
return;
}
let deletedCount = 0;
classes.forEach((className) => {
const elements = document.querySelectorAll(`.${className}`);
elements.forEach((element) => {
element.remove();
deletedCount++;
});
});
button.innerText = "Deleted";
button.style.backgroundColor = "#007bff";
button.style.color = "#fff";
button.style.cursor = "default";
button.style.pointerEvents = "none";
setTimeout(() => {
button.style.display = "none";
}, 1500);
});
});
}
});