Update rendered sticky notes when URL changes

This commit is contained in:
Idrees Hassan
2025-08-28 20:24:17 -04:00
parent f4dbd5047e
commit fed4adcf0a
4 changed files with 59 additions and 8 deletions

21
dist/birb.js vendored
View File

@@ -1278,14 +1278,31 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
}
});
drawStickyNotes();
let lastUrl = (window.location.href ?? "").split("?")[0];
setInterval(() => {
const currentUrl = (window.location.href ?? "").split("?")[0];
if (currentUrl !== lastUrl) {
log("URL changed, updating sticky notes");
lastUrl = currentUrl;
drawStickyNotes();
}
}, 500);
setInterval(update, 1000 / 60);
}
function drawStickyNotes() {
// Remove all existing sticky notes
const existingNotes = document.querySelectorAll(".birb-sticky-note");
existingNotes.forEach(note => note.remove());
// Render all sticky notes
for (let stickyNote of stickyNotes) {
if (isStickyNoteApplicable(stickyNote)) {
renderStickyNote(stickyNote);
}
}
setInterval(update, 1000 / 60);
}
function update() {