forked from TussockyJoker/Aula-Fixer
Now gets keywords.txt from repo on git.wbell.dev
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ Archive.zip
|
|||||||
.amo-upload-uuid
|
.amo-upload-uuid
|
||||||
dev-resources
|
dev-resources
|
||||||
content copy.js
|
content copy.js
|
||||||
|
aula-fixer_v1-2.zip
|
||||||
|
|||||||
34
background.js
Normal file
34
background.js
Normal 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/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;
|
||||||
|
}
|
||||||
|
});
|
||||||
25
content.js
25
content.js
@@ -1,11 +1,13 @@
|
|||||||
let keywords = [];
|
let keywords = [];
|
||||||
|
|
||||||
async function loadKeywords() {
|
function loadKeywords() {
|
||||||
try {
|
chrome.runtime.sendMessage({ type: "GET_KEYWORDS" }, (response) => {
|
||||||
const response = await fetch(chrome.runtime.getURL("keywords.txt"));
|
if (!response || !response.success) {
|
||||||
const text = await response.text();
|
console.error("Failed to load remote keywords:", response?.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
keywords = text
|
keywords = response.data
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.map(k => k.trim().toLowerCase())
|
.map(k => k.trim().toLowerCase())
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
@@ -14,10 +16,7 @@ async function loadKeywords() {
|
|||||||
|
|
||||||
injectStyles();
|
injectStyles();
|
||||||
startFiltering();
|
startFiltering();
|
||||||
|
});
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to load keywords.txt:", error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterNotifications() {
|
function filterNotifications() {
|
||||||
@@ -37,13 +36,16 @@ function filterNotifications() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function injectStyles() {
|
function injectStyles() {
|
||||||
|
// Prevent duplicate injection
|
||||||
|
if (document.getElementById("aula-fixer-styles")) return;
|
||||||
|
|
||||||
const style = document.createElement("style");
|
const style = document.createElement("style");
|
||||||
|
style.id = "aula-fixer-styles";
|
||||||
|
|
||||||
style.textContent = `
|
style.textContent = `
|
||||||
.css-qbgecn {
|
.css-qbgecn {
|
||||||
max-height: 99% !important;
|
max-height: 99% !important;
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.css-15ampbt {
|
.css-15ampbt {
|
||||||
@@ -64,8 +66,7 @@ function injectStyles() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.css-nivjaw {
|
.css-nivjaw {
|
||||||
padding: 12px 12px 12px 12px;
|
padding: 12px 12px 12px 12px !important;
|
||||||
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Aula Fixer",
|
"name": "Aula Fixer",
|
||||||
"version": "1.2",
|
"version": "1.3",
|
||||||
"description": "Removes all notifications about rooms for rent etc. on Aula and changes styling so that less screen space is wasted.",
|
"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"
|
||||||
|
},
|
||||||
|
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"matches": ["https://coventry.aula.education/*"],
|
"matches": ["https://coventry.aula.education/*"],
|
||||||
@@ -11,6 +15,10 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
"host_permissions": [
|
||||||
|
"https://git.wbell.dev/*"
|
||||||
|
],
|
||||||
|
|
||||||
"web_accessible_resources": [
|
"web_accessible_resources": [
|
||||||
{
|
{
|
||||||
"resources": ["keywords.txt"],
|
"resources": ["keywords.txt"],
|
||||||
@@ -20,11 +28,7 @@
|
|||||||
|
|
||||||
"browser_specific_settings": {
|
"browser_specific_settings": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
"id": "aula-fixer@tussockyjoker.com",
|
"id": "aula-fixer@tussockyjoker.com"
|
||||||
"data_collection_permissions": {
|
|
||||||
"required": ["none"],
|
|
||||||
"optional": []
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user