Now gets keywords from 'excludes.txt'
This commit is contained in:
48
content.js
48
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
|
||||
});
|
||||
// Watch for dynamically loaded notifications
|
||||
const observer = new MutationObserver(() => {
|
||||
filterNotifications();
|
||||
});
|
||||
|
||||
observer.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
}
|
||||
|
||||
// Start everything
|
||||
loadKeywords();
|
||||
5
excludes.txt
Normal file
5
excludes.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
tenancy
|
||||
bedroom available
|
||||
spacious room
|
||||
i'm looking for a place to rent
|
||||
short-term let available
|
||||
@@ -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/*"]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user