-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontent.js
37 lines (33 loc) · 1020 Bytes
/
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
// Function to retrieve and display bookmarked URLs
function displayBookmarks() {
chrome.bookmarks.getTree((bookmarkTree) => {
// Process the bookmark tree to extract URLs
const urls = [];
processBookmarks(bookmarkTree, urls);
// Display the URLs to the user
renderURLs(urls);
});
}
// Recursive function to process bookmark tree and extract URLs
function processBookmarks(bookmarkTree, urls) {
for (const node of bookmarkTree) {
if (node.url) {
urls.push(node.url);
} else if (node.children) {
processBookmarks(node.children, urls);
}
}
}
// Function to render bookmarked URLs to the user
function renderURLs(urls) {
const urlList = document.getElementById("urlList");
for (const url of urls) {
const listItem = document.createElement("li");
listItem.textContent = url;
urlList.appendChild(listItem);
}
}
// Call displayBookmarks function when the popup page loads
document.addEventListener("DOMContentLoaded", () => {
displayBookmarks();
});