forked from TussockyJoker/Aula-Fixer
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() {
|
function filterNotifications() {
|
||||||
const notifications = document.querySelectorAll('div[role="button"]');
|
const notifications = document.querySelectorAll('div[role="button"]');
|
||||||
|
|
||||||
@@ -17,15 +36,20 @@ function filterNotifications() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run once on load
|
function startFiltering() {
|
||||||
filterNotifications();
|
// Run once
|
||||||
|
|
||||||
// Watch for dynamically loaded notifications
|
|
||||||
const observer = new MutationObserver(() => {
|
|
||||||
filterNotifications();
|
filterNotifications();
|
||||||
});
|
|
||||||
|
|
||||||
observer.observe(document.body, {
|
// Watch for dynamically loaded notifications
|
||||||
childList: true,
|
const observer = new MutationObserver(() => {
|
||||||
subtree: true
|
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,
|
"manifest_version": 3,
|
||||||
"name": "Aula Ad Filter",
|
"name": "Aula Ad Filter",
|
||||||
"version": "1.0",
|
"version": "1.1",
|
||||||
"description": "Removes all the notifications about rooms for rent on Aula",
|
"description": "Removes all the notifications about rooms for rent on Aula",
|
||||||
"permissions": [],
|
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"matches": ["https://coventry.aula.education/*"],
|
"matches": ["https://coventry.aula.education/*"],
|
||||||
"js": ["content.js"]
|
"js": ["content.js"]
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"web_accessible_resources": [
|
||||||
|
{
|
||||||
|
"resources": ["excludes.txt"],
|
||||||
|
"matches": ["https://coventry.aula.education/*"]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user