diff --git a/.DS_Store b/.DS_Store index 1b8f36f..b9c2556 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/content.js b/content.js index 48f9dce..0f87f81 100644 --- a/content.js +++ b/content.js @@ -1,55 +1,51 @@ let keywords = []; -// Load excludes.txt first async function loadKeywords() { - try { - const response = await fetch(chrome.runtime.getURL("excludes.txt")); - const text = await response.text(); + try { + const response = await fetch(chrome.runtime.getURL("keywords.txt")); + const text = await response.text(); - keywords = text - .split("\n") - .map(k => k.trim().toLowerCase()) - .filter(Boolean); + keywords = text + .split("\n") + .map(k => k.trim().toLowerCase()) + .filter(Boolean); - console.log("Loaded keywords:", keywords); + console.log("Loaded keywords:", keywords); - startFiltering(); // start only after keywords are ready + startFiltering(); - } catch (error) { - console.error("Failed to load excludes.txt:", error); - } + } catch (error) { + console.error("Failed to load keywords.txt:", error); + } } function filterNotifications() { - const notifications = document.querySelectorAll('div[role="button"]'); + const notifications = document.querySelectorAll('div[role="button"]'); - notifications.forEach(notification => { - const text = notification.innerText.toLowerCase(); + notifications.forEach(notification => { + const text = notification.innerText.toLowerCase(); - const containsKeyword = keywords.some(keyword => - text.includes(keyword) - ); + const containsKeyword = keywords.some(keyword => + text.includes(keyword) + ); - if (containsKeyword) { - notification.remove(); - } - }); + if (containsKeyword) { + notification.remove(); + } + }); } function startFiltering() { - // Run once - filterNotifications(); - - // Watch for dynamically loaded notifications - const observer = new MutationObserver(() => { filterNotifications(); - }); - observer.observe(document.body, { - childList: true, - subtree: true - }); + const observer = new MutationObserver(() => { + filterNotifications(); + }); + + observer.observe(document.body, { + childList: true, + subtree: true + }); } -// Start everything loadKeywords(); \ No newline at end of file diff --git a/excludes.txt b/keywords.txt similarity index 100% rename from excludes.txt rename to keywords.txt diff --git a/manifest.json b/manifest.json index 5125d4e..6f67855 100644 --- a/manifest.json +++ b/manifest.json @@ -13,7 +13,7 @@ "web_accessible_resources": [ { - "resources": ["excludes.txt"], + "resources": ["keywords.txt"], "matches": ["https://coventry.aula.education/*"] } ]