Clean repo/README.md, add option to disable extension and bump version to 2.
This commit is contained in:
parent
96c36561e3
commit
9dc35139d6
7 changed files with 123 additions and 57 deletions
47
mango.js
47
mango.js
|
|
@ -1,26 +1,31 @@
|
|||
console.log("[Mango] Let's get the business done.")
|
||||
const currentHostname = location.hostname;
|
||||
let enabled = true;
|
||||
|
||||
browser.storage.local.get("enabled").then((result) => {
|
||||
enabled = result.enabled ?? true;
|
||||
}).catch((error) => {
|
||||
console.error("Error retrieving enabled state:", error);
|
||||
});
|
||||
|
||||
|
||||
function checkWhitelist(url) {
|
||||
return browser.storage.local.get("whitelist").then((result) => {
|
||||
const whitelist = result.whitelist || [];
|
||||
return whitelist.includes(url);
|
||||
});
|
||||
}
|
||||
|
||||
const currentHostname = location.hostname;
|
||||
|
||||
checkWhitelist(currentHostname).then((isWhitelisted) => {
|
||||
if (!isWhitelisted) {
|
||||
const styles = `
|
||||
return browser.storage.local.get("whitelist").then((result) => {
|
||||
const whitelist = result.whitelist || [];
|
||||
return whitelist.includes(url);
|
||||
});
|
||||
}
|
||||
|
||||
checkWhitelist(currentHostname).then((isWhitelisted) => {
|
||||
if (!isWhitelisted && enabled) {
|
||||
const styles = `
|
||||
* {
|
||||
border-radius: 0 !important;
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
`;
|
||||
const injectedStyle = document.createElement("style");
|
||||
injectedStyle.type = "text/css";
|
||||
injectedStyle.innerText = styles;
|
||||
document.head.appendChild(injectedStyle);
|
||||
} else {
|
||||
console.log("[Mango] Mercy! This page is whitelisted.")
|
||||
}
|
||||
});
|
||||
const injectedStyle = document.createElement("style");
|
||||
injectedStyle.type = "text/css";
|
||||
injectedStyle.id = "mangoInjectedStyle";
|
||||
injectedStyle.innerText = styles;
|
||||
document.head.appendChild(injectedStyle);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue