add .env support

This commit is contained in:
Ugric
2026-02-26 21:18:39 +00:00
parent 5fe2d981e8
commit ad17674577
12 changed files with 20 additions and 6 deletions

34
src/background.js Normal file
View File

@@ -0,0 +1,34 @@
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.type === "GET_KEYWORDS") {
const remoteUrl = "https://git.wbell.dev/TussockyJoker/Aula-Fixer/raw/branch/main/src/keywords.txt";
const localUrl = chrome.runtime.getURL("keywords.txt");
// remote
fetch(remoteUrl)
.then(response => {
if (!response.ok) throw new Error("Remote fetch failed");
return response.text();
})
.then(text => {
console.log("Loaded remote keywords");
sendResponse({ success: true, data: text });
})
.catch(() => {
console.warn("Remote failed, loading local fallback");
// local
fetch(localUrl)
.then(response => response.text())
.then(text => {
console.log("Loaded local fallback keywords");
sendResponse({ success: true, data: text });
})
.catch(error => {
sendResponse({ success: false, error: error.toString() });
});
});
return true;
}
});

89
src/content.js Normal file
View File

@@ -0,0 +1,89 @@
let keywords = [];
function loadKeywords() {
chrome.runtime.sendMessage({ type: "GET_KEYWORDS" }, (response) => {
if (!response || !response.success) {
console.error("Failed to load remote keywords:", response?.error);
return;
}
keywords = response.data
.split("\n")
.map(k => k.trim().toLowerCase())
.filter(Boolean);
console.log("Loaded keywords:", keywords);
injectStyles();
startFiltering();
});
}
function filterNotifications() {
const notifications = document.querySelectorAll('div[role="button"]');
notifications.forEach(notification => {
const text = notification.innerText?.toLowerCase() || "";
const containsKeyword = keywords.some(keyword =>
text.includes(keyword)
);
if (containsKeyword) {
notification.remove();
}
});
}
function injectStyles() {
// Prevent duplicate injection
if (document.getElementById("aula-fixer-styles")) return;
const style = document.createElement("style");
style.id = "aula-fixer-styles";
style.textContent = `
.css-qbgecn {
max-height: 99% !important;
padding: 0 !important;
}
.css-15ampbt {
overflow: hidden !important;
}
.css-1iji2l6 {
margin: 1px !important;
}
#main-content > div > div > div.css-qbgecn.e1f8gytw1 {
overflow-y: hidden !important;
}
.css-1vz9kb2 {
flex-basis: 85% !important;
padding: 0px 0px 0px 1% !important;
}
.css-nivjaw {
padding: 12px 12px 12px 12px !important;
}
`;
document.head.appendChild(style);
}
function startFiltering() {
filterNotifications();
const observer = new MutationObserver(() => {
filterNotifications();
});
observer.observe(document.body, {
childList: true,
subtree: true
});
}
loadKeywords();

19
src/keywords.txt Normal file
View File

@@ -0,0 +1,19 @@
tenancy
bedroom available
bedroom is available
spacious room
i'm looking for a place to rent
short-term let available
i am looking for accomodation
i'm looking for accomodation
fully furnished house
ensuite room available
room available cv13gx queens park house unite student
en-suite room available
double studio room is available
need a space for 1 person (girl) to stay
hey everyone looking space for one
room available for girl (shared accommodation)
takeover an en-suite room
i'm currently seeking for someone who can take over an en-suite room
accomodation alert

35
src/manifest.json Normal file
View File

@@ -0,0 +1,35 @@
{
"manifest_version": 3,
"name": "Aula Fixer",
"version": "1.3",
"description": "Removes all notifications about rooms for rent etc. on Aula and changes styling so that less screen space is wasted.",
"background": {
"service_worker": "background.js",
"scripts": ["background.js"]
},
"content_scripts": [
{
"matches": ["https://coventry.aula.education/*"],
"js": ["content.js"]
}
],
"host_permissions": [
"https://git.wbell.dev/*"
],
"web_accessible_resources": [
{
"resources": ["keywords.txt"],
"matches": ["https://coventry.aula.education/*"]
}
],
"browser_specific_settings": {
"gecko": {
"id": "aula-fixer@tussockyjoker.com"
}
}
}

35
src/manifest_chrome.json Normal file
View File

@@ -0,0 +1,35 @@
{
"manifest_version": 3,
"name": "Aula Fixer",
"version": "1.3",
"description": "Removes all notifications about rooms for rent etc. on Aula and changes styling so that less screen space is wasted.",
"background": {
"service_worker": "background.js",
"scripts": ["background.js"]
},
"content_scripts": [
{
"matches": ["https://coventry.aula.education/*"],
"js": ["content.js"]
}
],
"host_permissions": [
"https://git.wbell.dev/*"
],
"web_accessible_resources": [
{
"resources": ["keywords.txt"],
"matches": ["https://coventry.aula.education/*"]
}
],
"browser_specific_settings": {
"gecko": {
"id": "aula-fixer@tussockyjoker.com"
}
}
}

35
src/manifest_ff.json Normal file
View File

@@ -0,0 +1,35 @@
{
"manifest_version": 3,
"name": "Aula Fixer",
"version": "1.3",
"description": "Removes all notifications about rooms for rent etc. on Aula and changes styling so that less screen space is wasted.",
"background": {
"service_worker": "background.js",
"scripts": ["background.js"]
},
"content_scripts": [
{
"matches": ["https://coventry.aula.education/*"],
"js": ["content.js"]
}
],
"host_permissions": [
"https://git.wbell.dev/*"
],
"web_accessible_resources": [
{
"resources": ["keywords.txt"],
"matches": ["https://coventry.aula.education/*"]
}
],
"browser_specific_settings": {
"gecko": {
"id": "aula-fixer@tussockyjoker.com"
}
}
}