From fed4adcf0ad585bccea1df03a1008ffc9ebd4e6b Mon Sep 17 00:00:00 2001 From: Idrees Hassan Date: Thu, 28 Aug 2025 20:24:17 -0400 Subject: [PATCH] Update rendered sticky notes when URL changes --- birb.js | 21 +++++++++++++++++++-- build.js | 2 +- dist/birb.js | 21 +++++++++++++++++++-- dist/birb.user.js | 23 ++++++++++++++++++++--- 4 files changed, 59 insertions(+), 8 deletions(-) diff --git a/birb.js b/birb.js index 491563c..75648ea 100644 --- a/birb.js +++ b/birb.js @@ -958,14 +958,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() { diff --git a/build.js b/build.js index 383ac13..7b676b5 100644 --- a/build.js +++ b/build.js @@ -24,7 +24,7 @@ const userScriptHeader = `// ==UserScript== // @name Browser Bird // @namespace https://idreesinc.com -// @version 2025-08-28 +// @version 2025-08-28-1 // @description birb // @author Idrees // @downloadURL https://github.com/IdreesInc/Browser-Bird/raw/refs/heads/main/dist/birb.user.js diff --git a/dist/birb.js b/dist/birb.js index 994aa8e..a835716 100644 --- a/dist/birb.js +++ b/dist/birb.js @@ -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() { diff --git a/dist/birb.user.js b/dist/birb.user.js index 3d5eb0c..ed70484 100644 --- a/dist/birb.user.js +++ b/dist/birb.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Browser Bird // @namespace https://idreesinc.com -// @version 2025-08-28 +// @version 2025-08-28-1 // @description birb // @author Idrees // @downloadURL https://github.com/IdreesInc/Browser-Bird/raw/refs/heads/main/dist/birb.user.js @@ -1292,14 +1292,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() {