diff --git a/dist/birb.js b/dist/birb.js index 7180c24..3436801 100644 --- a/dist/birb.js +++ b/dist/birb.js @@ -880,6 +880,40 @@ resetSaveData() { throw new Error("Method not implemented"); } + + /** + * @returns {string} The current path of the active page in this context + */ + getPath() { + // Default to website URL + return window.location.href; + } + + /** + * Checks if a path is applicable given the context + * @param {string} path Can be a site URL or another context-specific path + * @returns {boolean} Whether the path matches the current context state + */ + isPathApplicable(path) { + // Default to website URL matching + const currentUrl = window.location.href; + const stickyNoteWebsite = path.split("?")[0]; + const currentWebsite = currentUrl.split("?")[0]; + + if (stickyNoteWebsite !== currentWebsite) { + return false; + } + + const pathParams = parseUrlParams(path); + const currentParams = parseUrlParams(currentUrl); + + if (window.location.hostname === "www.youtube.com") { + if (currentParams.v !== undefined && currentParams.v !== pathParams.v) { + return false; + } + } + return true; + } } class LocalContext extends Context { @@ -1063,6 +1097,21 @@ return new LocalContext(); } + /** + * Parse URL parameters into a key-value map + * @param {string} url + * @returns {Record} + */ + function parseUrlParams(url) { + const queryString = url.split("?")[1]; + if (!queryString) return {}; + + return queryString.split("&").reduce((params, param) => { + const [key, value] = param.split("="); + return { ...params, [key]: value }; + }, {}); + } + /** * @typedef {Object} SavedStickyNote * @property {string} id @@ -1089,46 +1138,6 @@ } } - /** - * Parse URL parameters into a key-value map - * @param {string} url - * @returns {Record} - */ - function parseUrlParams(url) { - const queryString = url.split("?")[1]; - if (!queryString) return {}; - - return queryString.split("&").reduce((params, param) => { - const [key, value] = param.split("="); - return { ...params, [key]: value }; - }, {}); - } - - /** - * @param {StickyNote} stickyNote - * @returns {boolean} Whether the given sticky note is applicable to the current site/page - */ - function isStickyNoteApplicable(stickyNote) { - const stickyNoteUrl = stickyNote.site; - const currentUrl = window.location.href; - const stickyNoteWebsite = stickyNoteUrl.split("?")[0]; - const currentWebsite = currentUrl.split("?")[0]; - - if (stickyNoteWebsite !== currentWebsite) { - return false; - } - - const stickyNoteParams = parseUrlParams(stickyNoteUrl); - const currentParams = parseUrlParams(currentUrl); - - if (window.location.hostname === "www.youtube.com") { - if (currentParams.v !== undefined && currentParams.v !== stickyNoteParams.v) { - return false; - } - } - return true; - } - /** * @param {StickyNote} stickyNote * @param {() => void} onSave @@ -1211,8 +1220,9 @@ const existingNotes = document.querySelectorAll(".birb-sticky-note"); existingNotes.forEach(note => note.remove()); // Render all sticky notes + const context = getContext(); for (let stickyNote of stickyNotes) { - if (isStickyNoteApplicable(stickyNote)) { + if (context.isPathApplicable(stickyNote.site)) { renderStickyNote(stickyNote, onSave, () => onDelete(stickyNote)); } } @@ -1225,7 +1235,7 @@ */ function createNewStickyNote(stickyNotes, onSave, onDelete) { const id = Date.now().toString(); - const site = window.location.href; + const site = getContext().getPath(); const stickyNote = new StickyNote(id, site, ""); const element = renderStickyNote(stickyNote, onSave, () => onDelete(stickyNote)); element.style.left = `${window.innerWidth / 2 - element.offsetWidth / 2}px`; @@ -1902,7 +1912,7 @@ insertModal(`${birdBirb()} Mode`, message); }), new Separator(), - new MenuItem("2025.11.13.2", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.2"); }, false), + new MenuItem("2025.11.13.6", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.6"); }, false), ]; const styleElement = document.createElement("style"); @@ -2097,12 +2107,12 @@ drawStickyNotes(stickyNotes, save, deleteStickyNote); - let lastUrl = (window.location.href ?? "").split("?")[0]; + let lastPath = getContext().getPath().split("?")[0]; setInterval(() => { - const currentUrl = (window.location.href ?? "").split("?")[0]; - if (currentUrl !== lastUrl) { - log("URL changed, updating sticky notes"); - lastUrl = currentUrl; + const currentPath = getContext().getPath().split("?")[0]; + if (currentPath !== lastPath) { + log("Path changed, updating sticky notes"); + lastPath = currentPath; drawStickyNotes(stickyNotes, save, deleteStickyNote); } }, URL_CHECK_INTERVAL); diff --git a/dist/extension.zip b/dist/extension.zip index 9198110..9374412 100644 Binary files a/dist/extension.zip and b/dist/extension.zip differ diff --git a/dist/extension/birb.js b/dist/extension/birb.js index 7180c24..3436801 100644 --- a/dist/extension/birb.js +++ b/dist/extension/birb.js @@ -880,6 +880,40 @@ resetSaveData() { throw new Error("Method not implemented"); } + + /** + * @returns {string} The current path of the active page in this context + */ + getPath() { + // Default to website URL + return window.location.href; + } + + /** + * Checks if a path is applicable given the context + * @param {string} path Can be a site URL or another context-specific path + * @returns {boolean} Whether the path matches the current context state + */ + isPathApplicable(path) { + // Default to website URL matching + const currentUrl = window.location.href; + const stickyNoteWebsite = path.split("?")[0]; + const currentWebsite = currentUrl.split("?")[0]; + + if (stickyNoteWebsite !== currentWebsite) { + return false; + } + + const pathParams = parseUrlParams(path); + const currentParams = parseUrlParams(currentUrl); + + if (window.location.hostname === "www.youtube.com") { + if (currentParams.v !== undefined && currentParams.v !== pathParams.v) { + return false; + } + } + return true; + } } class LocalContext extends Context { @@ -1063,6 +1097,21 @@ return new LocalContext(); } + /** + * Parse URL parameters into a key-value map + * @param {string} url + * @returns {Record} + */ + function parseUrlParams(url) { + const queryString = url.split("?")[1]; + if (!queryString) return {}; + + return queryString.split("&").reduce((params, param) => { + const [key, value] = param.split("="); + return { ...params, [key]: value }; + }, {}); + } + /** * @typedef {Object} SavedStickyNote * @property {string} id @@ -1089,46 +1138,6 @@ } } - /** - * Parse URL parameters into a key-value map - * @param {string} url - * @returns {Record} - */ - function parseUrlParams(url) { - const queryString = url.split("?")[1]; - if (!queryString) return {}; - - return queryString.split("&").reduce((params, param) => { - const [key, value] = param.split("="); - return { ...params, [key]: value }; - }, {}); - } - - /** - * @param {StickyNote} stickyNote - * @returns {boolean} Whether the given sticky note is applicable to the current site/page - */ - function isStickyNoteApplicable(stickyNote) { - const stickyNoteUrl = stickyNote.site; - const currentUrl = window.location.href; - const stickyNoteWebsite = stickyNoteUrl.split("?")[0]; - const currentWebsite = currentUrl.split("?")[0]; - - if (stickyNoteWebsite !== currentWebsite) { - return false; - } - - const stickyNoteParams = parseUrlParams(stickyNoteUrl); - const currentParams = parseUrlParams(currentUrl); - - if (window.location.hostname === "www.youtube.com") { - if (currentParams.v !== undefined && currentParams.v !== stickyNoteParams.v) { - return false; - } - } - return true; - } - /** * @param {StickyNote} stickyNote * @param {() => void} onSave @@ -1211,8 +1220,9 @@ const existingNotes = document.querySelectorAll(".birb-sticky-note"); existingNotes.forEach(note => note.remove()); // Render all sticky notes + const context = getContext(); for (let stickyNote of stickyNotes) { - if (isStickyNoteApplicable(stickyNote)) { + if (context.isPathApplicable(stickyNote.site)) { renderStickyNote(stickyNote, onSave, () => onDelete(stickyNote)); } } @@ -1225,7 +1235,7 @@ */ function createNewStickyNote(stickyNotes, onSave, onDelete) { const id = Date.now().toString(); - const site = window.location.href; + const site = getContext().getPath(); const stickyNote = new StickyNote(id, site, ""); const element = renderStickyNote(stickyNote, onSave, () => onDelete(stickyNote)); element.style.left = `${window.innerWidth / 2 - element.offsetWidth / 2}px`; @@ -1902,7 +1912,7 @@ insertModal(`${birdBirb()} Mode`, message); }), new Separator(), - new MenuItem("2025.11.13.2", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.2"); }, false), + new MenuItem("2025.11.13.6", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.6"); }, false), ]; const styleElement = document.createElement("style"); @@ -2097,12 +2107,12 @@ drawStickyNotes(stickyNotes, save, deleteStickyNote); - let lastUrl = (window.location.href ?? "").split("?")[0]; + let lastPath = getContext().getPath().split("?")[0]; setInterval(() => { - const currentUrl = (window.location.href ?? "").split("?")[0]; - if (currentUrl !== lastUrl) { - log("URL changed, updating sticky notes"); - lastUrl = currentUrl; + const currentPath = getContext().getPath().split("?")[0]; + if (currentPath !== lastPath) { + log("Path changed, updating sticky notes"); + lastPath = currentPath; drawStickyNotes(stickyNotes, save, deleteStickyNote); } }, URL_CHECK_INTERVAL); diff --git a/dist/extension/manifest.json b/dist/extension/manifest.json index 6afbae5..cc12b0a 100644 --- a/dist/extension/manifest.json +++ b/dist/extension/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "Pocket Bird", "description": "It's a pet bird in your browser, what more could you want?", - "version": "2025.11.13.2", + "version": "2025.11.13.6", "homepage_url": "https://idreesinc.com", "icons": { "48": "images/icons/transparent/48x48x1.png", diff --git a/dist/obsidian/main.js b/dist/obsidian/main.js index c63c8bc..91d0ecb 100644 --- a/dist/obsidian/main.js +++ b/dist/obsidian/main.js @@ -884,6 +884,40 @@ module.exports = class MyPlugin extends Plugin { resetSaveData() { throw new Error("Method not implemented"); } + + /** + * @returns {string} The current path of the active page in this context + */ + getPath() { + // Default to website URL + return window.location.href; + } + + /** + * Checks if a path is applicable given the context + * @param {string} path Can be a site URL or another context-specific path + * @returns {boolean} Whether the path matches the current context state + */ + isPathApplicable(path) { + // Default to website URL matching + const currentUrl = window.location.href; + const stickyNoteWebsite = path.split("?")[0]; + const currentWebsite = currentUrl.split("?")[0]; + + if (stickyNoteWebsite !== currentWebsite) { + return false; + } + + const pathParams = parseUrlParams(path); + const currentParams = parseUrlParams(currentUrl); + + if (window.location.hostname === "www.youtube.com") { + if (currentParams.v !== undefined && currentParams.v !== pathParams.v) { + return false; + } + } + return true; + } } class LocalContext extends Context { @@ -1067,6 +1101,21 @@ module.exports = class MyPlugin extends Plugin { return new LocalContext(); } + /** + * Parse URL parameters into a key-value map + * @param {string} url + * @returns {Record} + */ + function parseUrlParams(url) { + const queryString = url.split("?")[1]; + if (!queryString) return {}; + + return queryString.split("&").reduce((params, param) => { + const [key, value] = param.split("="); + return { ...params, [key]: value }; + }, {}); + } + /** * @typedef {Object} SavedStickyNote * @property {string} id @@ -1093,46 +1142,6 @@ module.exports = class MyPlugin extends Plugin { } } - /** - * Parse URL parameters into a key-value map - * @param {string} url - * @returns {Record} - */ - function parseUrlParams(url) { - const queryString = url.split("?")[1]; - if (!queryString) return {}; - - return queryString.split("&").reduce((params, param) => { - const [key, value] = param.split("="); - return { ...params, [key]: value }; - }, {}); - } - - /** - * @param {StickyNote} stickyNote - * @returns {boolean} Whether the given sticky note is applicable to the current site/page - */ - function isStickyNoteApplicable(stickyNote) { - const stickyNoteUrl = stickyNote.site; - const currentUrl = window.location.href; - const stickyNoteWebsite = stickyNoteUrl.split("?")[0]; - const currentWebsite = currentUrl.split("?")[0]; - - if (stickyNoteWebsite !== currentWebsite) { - return false; - } - - const stickyNoteParams = parseUrlParams(stickyNoteUrl); - const currentParams = parseUrlParams(currentUrl); - - if (window.location.hostname === "www.youtube.com") { - if (currentParams.v !== undefined && currentParams.v !== stickyNoteParams.v) { - return false; - } - } - return true; - } - /** * @param {StickyNote} stickyNote * @param {() => void} onSave @@ -1215,8 +1224,9 @@ module.exports = class MyPlugin extends Plugin { const existingNotes = document.querySelectorAll(".birb-sticky-note"); existingNotes.forEach(note => note.remove()); // Render all sticky notes + const context = getContext(); for (let stickyNote of stickyNotes) { - if (isStickyNoteApplicable(stickyNote)) { + if (context.isPathApplicable(stickyNote.site)) { renderStickyNote(stickyNote, onSave, () => onDelete(stickyNote)); } } @@ -1229,7 +1239,7 @@ module.exports = class MyPlugin extends Plugin { */ function createNewStickyNote(stickyNotes, onSave, onDelete) { const id = Date.now().toString(); - const site = window.location.href; + const site = getContext().getPath(); const stickyNote = new StickyNote(id, site, ""); const element = renderStickyNote(stickyNote, onSave, () => onDelete(stickyNote)); element.style.left = `${window.innerWidth / 2 - element.offsetWidth / 2}px`; @@ -1906,7 +1916,7 @@ module.exports = class MyPlugin extends Plugin { insertModal(`${birdBirb()} Mode`, message); }), new Separator(), - new MenuItem("2025.11.13.2", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.2"); }, false), + new MenuItem("2025.11.13.6", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.6"); }, false), ]; const styleElement = document.createElement("style"); @@ -2101,12 +2111,12 @@ module.exports = class MyPlugin extends Plugin { drawStickyNotes(stickyNotes, save, deleteStickyNote); - let lastUrl = (window.location.href ?? "").split("?")[0]; + let lastPath = getContext().getPath().split("?")[0]; setInterval(() => { - const currentUrl = (window.location.href ?? "").split("?")[0]; - if (currentUrl !== lastUrl) { - log("URL changed, updating sticky notes"); - lastUrl = currentUrl; + const currentPath = getContext().getPath().split("?")[0]; + if (currentPath !== lastPath) { + log("Path changed, updating sticky notes"); + lastPath = currentPath; drawStickyNotes(stickyNotes, save, deleteStickyNote); } }, URL_CHECK_INTERVAL); diff --git a/dist/obsidian/manifest.json b/dist/obsidian/manifest.json index a55a7fa..c2d4666 100644 --- a/dist/obsidian/manifest.json +++ b/dist/obsidian/manifest.json @@ -1,7 +1,7 @@ { "id": "pocket-bird", "name": "Pocket Bird", - "version": "2025.11.13.2", + "version": "2025.11.13.6", "minAppVersion": "0.15.0", "description": "It's a pet bird in your Obsidian, what more could you want?", "author": "Idrees Hassan", diff --git a/dist/userscript/birb.user.js b/dist/userscript/birb.user.js index c05ddb3..6201bbe 100644 --- a/dist/userscript/birb.user.js +++ b/dist/userscript/birb.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Pocket Bird // @namespace https://idreesinc.com -// @version 2025.11.13.2 +// @version 2025.11.13.6 // @description It's a bird that hops around your web browser, the future is here // @author Idrees // @downloadURL https://github.com/IdreesInc/Pocket-Bird/raw/refs/heads/main/dist/userscript/birb.user.js @@ -894,6 +894,40 @@ resetSaveData() { throw new Error("Method not implemented"); } + + /** + * @returns {string} The current path of the active page in this context + */ + getPath() { + // Default to website URL + return window.location.href; + } + + /** + * Checks if a path is applicable given the context + * @param {string} path Can be a site URL or another context-specific path + * @returns {boolean} Whether the path matches the current context state + */ + isPathApplicable(path) { + // Default to website URL matching + const currentUrl = window.location.href; + const stickyNoteWebsite = path.split("?")[0]; + const currentWebsite = currentUrl.split("?")[0]; + + if (stickyNoteWebsite !== currentWebsite) { + return false; + } + + const pathParams = parseUrlParams(path); + const currentParams = parseUrlParams(currentUrl); + + if (window.location.hostname === "www.youtube.com") { + if (currentParams.v !== undefined && currentParams.v !== pathParams.v) { + return false; + } + } + return true; + } } class LocalContext extends Context { @@ -1077,6 +1111,21 @@ return new LocalContext(); } + /** + * Parse URL parameters into a key-value map + * @param {string} url + * @returns {Record} + */ + function parseUrlParams(url) { + const queryString = url.split("?")[1]; + if (!queryString) return {}; + + return queryString.split("&").reduce((params, param) => { + const [key, value] = param.split("="); + return { ...params, [key]: value }; + }, {}); + } + /** * @typedef {Object} SavedStickyNote * @property {string} id @@ -1103,46 +1152,6 @@ } } - /** - * Parse URL parameters into a key-value map - * @param {string} url - * @returns {Record} - */ - function parseUrlParams(url) { - const queryString = url.split("?")[1]; - if (!queryString) return {}; - - return queryString.split("&").reduce((params, param) => { - const [key, value] = param.split("="); - return { ...params, [key]: value }; - }, {}); - } - - /** - * @param {StickyNote} stickyNote - * @returns {boolean} Whether the given sticky note is applicable to the current site/page - */ - function isStickyNoteApplicable(stickyNote) { - const stickyNoteUrl = stickyNote.site; - const currentUrl = window.location.href; - const stickyNoteWebsite = stickyNoteUrl.split("?")[0]; - const currentWebsite = currentUrl.split("?")[0]; - - if (stickyNoteWebsite !== currentWebsite) { - return false; - } - - const stickyNoteParams = parseUrlParams(stickyNoteUrl); - const currentParams = parseUrlParams(currentUrl); - - if (window.location.hostname === "www.youtube.com") { - if (currentParams.v !== undefined && currentParams.v !== stickyNoteParams.v) { - return false; - } - } - return true; - } - /** * @param {StickyNote} stickyNote * @param {() => void} onSave @@ -1225,8 +1234,9 @@ const existingNotes = document.querySelectorAll(".birb-sticky-note"); existingNotes.forEach(note => note.remove()); // Render all sticky notes + const context = getContext(); for (let stickyNote of stickyNotes) { - if (isStickyNoteApplicable(stickyNote)) { + if (context.isPathApplicable(stickyNote.site)) { renderStickyNote(stickyNote, onSave, () => onDelete(stickyNote)); } } @@ -1239,7 +1249,7 @@ */ function createNewStickyNote(stickyNotes, onSave, onDelete) { const id = Date.now().toString(); - const site = window.location.href; + const site = getContext().getPath(); const stickyNote = new StickyNote(id, site, ""); const element = renderStickyNote(stickyNote, onSave, () => onDelete(stickyNote)); element.style.left = `${window.innerWidth / 2 - element.offsetWidth / 2}px`; @@ -1916,7 +1926,7 @@ insertModal(`${birdBirb()} Mode`, message); }), new Separator(), - new MenuItem("2025.11.13.2", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.2"); }, false), + new MenuItem("2025.11.13.6", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.13.6"); }, false), ]; const styleElement = document.createElement("style"); @@ -2111,12 +2121,12 @@ drawStickyNotes(stickyNotes, save, deleteStickyNote); - let lastUrl = (window.location.href ?? "").split("?")[0]; + let lastPath = getContext().getPath().split("?")[0]; setInterval(() => { - const currentUrl = (window.location.href ?? "").split("?")[0]; - if (currentUrl !== lastUrl) { - log("URL changed, updating sticky notes"); - lastUrl = currentUrl; + const currentPath = getContext().getPath().split("?")[0]; + if (currentPath !== lastPath) { + log("Path changed, updating sticky notes"); + lastPath = currentPath; drawStickyNotes(stickyNotes, save, deleteStickyNote); } }, URL_CHECK_INTERVAL); diff --git a/src/application.js b/src/application.js index 5ab3814..9ce19c4 100644 --- a/src/application.js +++ b/src/application.js @@ -426,12 +426,12 @@ Promise.all([ drawStickyNotes(stickyNotes, save, deleteStickyNote); - let lastUrl = (window.location.href ?? "").split("?")[0]; + let lastPath = getContext().getPath().split("?")[0]; setInterval(() => { - const currentUrl = (window.location.href ?? "").split("?")[0]; - if (currentUrl !== lastUrl) { - log("URL changed, updating sticky notes"); - lastUrl = currentUrl; + const currentPath = getContext().getPath().split("?")[0]; + if (currentPath !== lastPath) { + log("Path changed, updating sticky notes"); + lastPath = currentPath; drawStickyNotes(stickyNotes, save, deleteStickyNote); } }, URL_CHECK_INTERVAL); diff --git a/src/context.js b/src/context.js index d3ada8e..ddc8de3 100644 --- a/src/context.js +++ b/src/context.js @@ -1,4 +1,3 @@ - import { debug, log, error } from "./shared.js"; const SAVE_KEY = "birbSaveData"; @@ -42,6 +41,40 @@ export class Context { resetSaveData() { throw new Error("Method not implemented"); } + + /** + * @returns {string} The current path of the active page in this context + */ + getPath() { + // Default to website URL + return window.location.href; + } + + /** + * Checks if a path is applicable given the context + * @param {string} path Can be a site URL or another context-specific path + * @returns {boolean} Whether the path matches the current context state + */ + isPathApplicable(path) { + // Default to website URL matching + const currentUrl = window.location.href; + const stickyNoteWebsite = path.split("?")[0]; + const currentWebsite = currentUrl.split("?")[0]; + + if (stickyNoteWebsite !== currentWebsite) { + return false; + } + + const pathParams = parseUrlParams(path); + const currentParams = parseUrlParams(currentUrl); + + if (window.location.hostname === "www.youtube.com") { + if (currentParams.v !== undefined && currentParams.v !== pathParams.v) { + return false; + } + } + return true; + } } export class LocalContext extends Context { @@ -223,4 +256,19 @@ export function getContext() { } error("No applicable context found, defaulting to LocalContext"); return new LocalContext(); +} + +/** + * Parse URL parameters into a key-value map + * @param {string} url + * @returns {Record} + */ +function parseUrlParams(url) { + const queryString = url.split("?")[1]; + if (!queryString) return {}; + + return queryString.split("&").reduce((params, param) => { + const [key, value] = param.split("="); + return { ...params, [key]: value }; + }, {}); } \ No newline at end of file diff --git a/src/stickyNotes.js b/src/stickyNotes.js index 29e7d8e..8e9c523 100644 --- a/src/stickyNotes.js +++ b/src/stickyNotes.js @@ -3,6 +3,7 @@ import { makeDraggable, makeClosable } from './shared.js'; +import { getContext } from './context.js'; /** * @typedef {Object} SavedStickyNote @@ -30,46 +31,6 @@ export class StickyNote { } } -/** - * Parse URL parameters into a key-value map - * @param {string} url - * @returns {Record} - */ -export function parseUrlParams(url) { - const queryString = url.split("?")[1]; - if (!queryString) return {}; - - return queryString.split("&").reduce((params, param) => { - const [key, value] = param.split("="); - return { ...params, [key]: value }; - }, {}); -} - -/** - * @param {StickyNote} stickyNote - * @returns {boolean} Whether the given sticky note is applicable to the current site/page - */ -export function isStickyNoteApplicable(stickyNote) { - const stickyNoteUrl = stickyNote.site; - const currentUrl = window.location.href; - const stickyNoteWebsite = stickyNoteUrl.split("?")[0]; - const currentWebsite = currentUrl.split("?")[0]; - - if (stickyNoteWebsite !== currentWebsite) { - return false; - } - - const stickyNoteParams = parseUrlParams(stickyNoteUrl); - const currentParams = parseUrlParams(currentUrl); - - if (window.location.hostname === "www.youtube.com") { - if (currentParams.v !== undefined && currentParams.v !== stickyNoteParams.v) { - return false; - } - } - return true; -} - /** * @param {StickyNote} stickyNote * @param {() => void} onSave @@ -152,8 +113,9 @@ export function drawStickyNotes(stickyNotes, onSave, onDelete) { const existingNotes = document.querySelectorAll(".birb-sticky-note"); existingNotes.forEach(note => note.remove()); // Render all sticky notes + const context = getContext(); for (let stickyNote of stickyNotes) { - if (isStickyNoteApplicable(stickyNote)) { + if (context.isPathApplicable(stickyNote.site)) { renderStickyNote(stickyNote, onSave, () => onDelete(stickyNote)); } } @@ -166,7 +128,7 @@ export function drawStickyNotes(stickyNotes, onSave, onDelete) { */ export function createNewStickyNote(stickyNotes, onSave, onDelete) { const id = Date.now().toString(); - const site = window.location.href; + const site = getContext().getPath(); const stickyNote = new StickyNote(id, site, ""); const element = renderStickyNote(stickyNote, onSave, () => onDelete(stickyNote)); element.style.left = `${window.innerWidth / 2 - element.offsetWidth / 2}px`;