2026-01-04 19:28:14 +00:00
|
|
|
// Embermarks - Popup Script
|
|
|
|
|
|
2026-01-05 02:36:05 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", async () => {
|
|
|
|
|
const container = document.getElementById("bookmarks");
|
|
|
|
|
const refreshBtn = document.getElementById("refresh");
|
|
|
|
|
|
|
|
|
|
// Load bookmarks (respects cache settings)
|
|
|
|
|
await loadBookmarks(container, false);
|
|
|
|
|
|
|
|
|
|
// Refresh button always forces a fresh load
|
|
|
|
|
refreshBtn.addEventListener("click", async () => {
|
|
|
|
|
await loadBookmarks(container, true);
|
2026-01-04 19:28:14 +00:00
|
|
|
});
|
|
|
|
|
});
|
2026-01-05 02:36:05 +00:00
|
|
|
|
|
|
|
|
// Load and display bookmarks
|
|
|
|
|
async function loadBookmarks(container, forceRefresh) {
|
|
|
|
|
showLoading(container);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const bookmarks = await browser.runtime.sendMessage({
|
|
|
|
|
action: "getForgottenBookmarks",
|
|
|
|
|
forceRefresh: forceRefresh,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
while (container.firstChild) {
|
|
|
|
|
container.removeChild(container.firstChild);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bookmarks || bookmarks.length === 0) {
|
|
|
|
|
showEmptyState(container, "none");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const bookmark of bookmarks) {
|
|
|
|
|
container.appendChild(createBookmarkCard(bookmark));
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Failed to load bookmarks:", error);
|
|
|
|
|
showError(container);
|
|
|
|
|
}
|
|
|
|
|
}
|