-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock.js
More file actions
39 lines (35 loc) · 1.21 KB
/
block.js
File metadata and controls
39 lines (35 loc) · 1.21 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
const textarea = document.getElementById("textarea");
const save = document.getElementById("save");
const checkbox = document.getElementById("checkbox");
save.addEventListener("click", () => {
const blocked = textarea.value.split("\n").map(s => s.trim()).filter(Boolean);
chrome.storage.local.set({ blocked });
alert("Changes Saved");
});
checkbox.addEventListener("change", (event) => {
const enabled = event.target.checked;
chrome.storage.local.set({ enabled });
});
window.addEventListener("DOMContentLoaded", () => {
chrome.storage.local.get(["blocked", "enabled"], function (local) {
const { blocked, enabled } = local;
if (Array.isArray(blocked)) {
textarea.value = blocked.join("\n");
checkbox.checked = enabled;
}
});
});
const buttons = document.querySelectorAll('a');
buttons.forEach(btn => {
btn.addEventListener('click', function (e) {
let x = e.clientX - e.target.offsetLeft;
let y = e.clientY - e.target.offsetTop;
let ripples = document.createElement('span');
ripples.style.left = x + 'px';
ripples.style.top = y + 'px';
this.appendChild(ripples);
setTimeout(() => {
ripples.remove()
}, 1000);
})
})