diff --git a/content.js b/content.js index fe66e04..48f9dce 100644 --- a/content.js +++ b/content.js @@ -1,6 +1,25 @@ -const keywords = ["tenancy", "bedroom available", "spacious room", "room available cv13GX queens park house unite student"]; +let keywords = []; + +// Load excludes.txt first +async function loadKeywords() { + try { + const response = await fetch(chrome.runtime.getURL("excludes.txt")); + const text = await response.text(); + + keywords = text + .split("\n") + .map(k => k.trim().toLowerCase()) + .filter(Boolean); + + console.log("Loaded keywords:", keywords); + + startFiltering(); // start only after keywords are ready + + } catch (error) { + console.error("Failed to load excludes.txt:", error); + } +} -// Function to check and remove matching notifications function filterNotifications() { const notifications = document.querySelectorAll('div[role="button"]'); @@ -17,15 +36,20 @@ function filterNotifications() { }); } -// Run once on load -filterNotifications(); - -// Watch for dynamically loaded notifications -const observer = new MutationObserver(() => { +function startFiltering() { + // Run once filterNotifications(); -}); -observer.observe(document.body, { - childList: true, - subtree: true -}); \ No newline at end of file + // Watch for dynamically loaded notifications + 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/excludes.txt new file mode 100644 index 0000000..24fac81 --- /dev/null +++ b/excludes.txt @@ -0,0 +1,5 @@ +tenancy +bedroom available +spacious room +i'm looking for a place to rent +short-term let available \ No newline at end of file diff --git a/manifest.json b/manifest.json index ca106fd..5125d4e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,13 +1,20 @@ { "manifest_version": 3, "name": "Aula Ad Filter", - "version": "1.0", + "version": "1.1", "description": "Removes all the notifications about rooms for rent on Aula", - "permissions": [], + "content_scripts": [ { "matches": ["https://coventry.aula.education/*"], "js": ["content.js"] } + ], + + "web_accessible_resources": [ + { + "resources": ["excludes.txt"], + "matches": ["https://coventry.aula.education/*"] + } ] } \ No newline at end of file