-
Notifications
You must be signed in to change notification settings - Fork 9
/
popup.js
27 lines (24 loc) · 816 Bytes
/
popup.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
async function createList() {
const { SAVED_URL_KEY } = await chrome.storage.sync.get("SAVED_URL_KEY");
const { SAVED_URL_KEY_LIST = [] } = await chrome.storage.sync.get(
"SAVED_URL_KEY_LIST"
);
const saveURLs = new Set(SAVED_URL_KEY_LIST);
if (!saveURLs.has(SAVED_URL_KEY)) {
saveURLs.add(SAVED_URL_KEY);
}
const mainList = document.getElementById("prev-url-list");
const header = document.getElementById("header-list");
if (saveURLs.size > 0) {
header.style.display = "block";
for (const savedURL of saveURLs) {
const li = document.createElement("li");
li.textContent = savedURL;
mainList.appendChild(li);
}
await chrome.storage.sync.set({ SAVED_URL_KEY_LIST: Array.from(saveURLs) });
}
}
createList().catch((error) => {
console.error(error);
});