-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
44 lines (38 loc) · 1.4 KB
/
popup.js
File metadata and controls
44 lines (38 loc) · 1.4 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
40
41
42
43
44
document.getElementById("highlightBtn").addEventListener("click", () => {
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, { action: "highlight" });
});
});
document.getElementById("clearBtn").addEventListener("click", () => {
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, { action: "clearHighlights" });
});
});
document.getElementById("refresh").addEventListener("click", () => {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, { action: "pprestoreHighlights" });
});
});
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
loadHighlights(tabs[0].url);
});
function loadHighlights(url) {
chrome.storage.local.get([url], (data) => {
const highlights = data[url] || [];
const list = document.getElementById("highlightItems");
list.innerHTML = "";
if (highlights.length === 0) {
const li = document.createElement("p");
li.textContent = "No highlights found.";
li.style.color = "#888";
li.style.fontStyle = "italic";
list.appendChild(li);
return;
}
highlights.forEach((item, index) => {
const li = document.createElement("li");
li.textContent = `${item.text}`;
list.appendChild(li);
});
});
}