Implemented whitelist.
This commit is contained in:
parent
b582390d2c
commit
bcfe8fdfab
6 changed files with 116 additions and 10 deletions
BIN
img/mango-full.jpg
Normal file
BIN
img/mango-full.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 637 KiB |
18
mango.html
18
mango.html
|
|
@ -1 +1,17 @@
|
||||||
<p>follow development at <a href="https://git.disroot.org/adrianvictor/mango">Git</a></p>
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Mango</title>
|
||||||
|
<script src="mangoui.js" defer></script>
|
||||||
|
<link rel="stylesheet" href="mangoUI.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1 id="title">mango</h1>
|
||||||
|
<h2 id="source">whitelist</h2>
|
||||||
|
<textarea placeholder="Domain only, separated by new line, see the example:
|
||||||
|
example.com
|
||||||
|
example2.com" id="whitelist" rows="10" cols="30"></textarea><br>
|
||||||
|
<button id="whitelistSave">save</button>
|
||||||
|
<p><a href="https://git.disroot.org/adrianvictor/mango">source-code</a></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
||||||
31
mango.js
31
mango.js
|
|
@ -1,9 +1,26 @@
|
||||||
var styles = `
|
console.log("[Mango] Let's get the business done.")
|
||||||
* {
|
|
||||||
|
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 = `
|
||||||
|
* {
|
||||||
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.")
|
||||||
}
|
}
|
||||||
`
|
});
|
||||||
var injectedStyle = document.createElement("style")
|
|
||||||
injectedStyle.type = "text/css"
|
|
||||||
injectedStyle.innerText = styles
|
|
||||||
document.head.appendChild(injectedStyle)
|
|
||||||
|
|
|
||||||
51
mangoUI.css
Normal file
51
mangoUI.css
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
body {
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: orangered;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
body::before {
|
||||||
|
content: "";
|
||||||
|
background-image: url(/img/mango-full.jpg);
|
||||||
|
position: absolute;
|
||||||
|
background-size: cover;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: -1;
|
||||||
|
opacity: .25;
|
||||||
|
}
|
||||||
|
|
||||||
|
#whitelist {
|
||||||
|
background-color: black;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#title {
|
||||||
|
font-weight: 300;
|
||||||
|
font-size: 50px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#whitelistSave {
|
||||||
|
border: 1px solid white;
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
font-size: large;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-weight: 300;
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
14
mangoui.js
Normal file
14
mangoui.js
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
document.getElementById('whitelistSave').addEventListener('click', () => {
|
||||||
|
const whitelist = document.getElementById('whitelist').value.split('\n').map(line => line.trim()).filter(line => line);
|
||||||
|
browser.storage.local.set({ whitelist: whitelist });
|
||||||
|
console.log('Whitelist saved!');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
browser.storage.local.get("whitelist").then((result) => {
|
||||||
|
const whitelist = result.whitelist || [];
|
||||||
|
document.getElementById('whitelist').value = whitelist.join('\n');
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error("Error retrieving the whitelist:", error);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
@ -2,13 +2,16 @@
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Mango",
|
"name": "Mango",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
|
|
||||||
"description": "Obliterates rounded corners.",
|
"description": "Obliterates rounded corners.",
|
||||||
|
|
||||||
"icons": {
|
"icons": {
|
||||||
"48": "img/mango-48.jpg",
|
"48": "img/mango-48.jpg",
|
||||||
"96": "img/mango-96.jpg"
|
"96": "img/mango-96.jpg"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"default_icon": {
|
||||||
|
"96": "img/mango-96.jpg"
|
||||||
|
},
|
||||||
|
|
||||||
"browser_specific_settings": {
|
"browser_specific_settings": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
|
|
@ -21,6 +24,11 @@
|
||||||
"default_title": "Mango",
|
"default_title": "Mango",
|
||||||
"default_popup": "mango.html"
|
"default_popup": "mango.html"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"permissions": [
|
||||||
|
"storage",
|
||||||
|
"activeTab"
|
||||||
|
],
|
||||||
|
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue