Now gets keywords.txt from repo on git.wbell.dev
This commit is contained in:
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;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user