Initial Commit, minimal viable version. Buggy but does work 'most' of the time :-)
This commit is contained in:
parent
963e202fa7
commit
a71c043202
7 changed files with 158 additions and 0 deletions
24
bolcom-3rdparty-filter/background.js
Normal file
24
bolcom-3rdparty-filter/background.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
function startFilter(result) {
|
||||
console.log('Got: ' + result.filter.enabled)
|
||||
if (result.filter.enabled == true) {
|
||||
|
||||
function redirect(requestDetails) {
|
||||
console.log(`Redirecting: ${requestDetails.url}`);
|
||||
if (requestDetails.url.includes("&sellerId=0")) { console.log('Nothing to do'); return; } else {
|
||||
return { redirectUrl: requestDetails.url+"&sellerId=0",};
|
||||
}
|
||||
}
|
||||
|
||||
browser.webRequest.onBeforeRequest.addListener(redirect, {
|
||||
urls: ["*://*.bol.com/*searchtext=*"],
|
||||
}, ["blocking"],);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
function onError(error) {
|
||||
console.log('Error: ${error}');
|
||||
}
|
||||
|
||||
let getting = browser.storage.local.get("filter");
|
||||
getting.then(startFilter, onError);
|
||||
BIN
bolcom-3rdparty-filter/icons/icon-32.png
Normal file
BIN
bolcom-3rdparty-filter/icons/icon-32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3 KiB |
BIN
bolcom-3rdparty-filter/icons/icon-48.png
Normal file
BIN
bolcom-3rdparty-filter/icons/icon-48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
26
bolcom-3rdparty-filter/manifest.json
Normal file
26
bolcom-3rdparty-filter/manifest.json
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
|
||||
"description": "Voegt een filter toggle toe aan bol.com pagina's om snel alle onderverkopers weg te filteren uit je zoekresultaten.",
|
||||
"manifest_version": 2,
|
||||
"name": "bolcom-3rdparty-filter",
|
||||
"version": "1.0",
|
||||
"homepage_url": "https://git.phiax.nl/PHiAX/bolcom-3rdparty-filter",
|
||||
"permissions": ["storage", "webRequest", "webRequestBlocking", "*://*.bol.com/*"],
|
||||
"browser_action": {
|
||||
"default_icon": {
|
||||
"32": "icons/icon-32.png",
|
||||
"48": "icons/icon-48.png"
|
||||
},
|
||||
"default_popup": "popup/filter.html"
|
||||
},
|
||||
|
||||
"background": {
|
||||
"scripts": ["background.js"]
|
||||
},
|
||||
|
||||
"browser_specific_settings": {
|
||||
"gecko": {
|
||||
"id": "phiax@bolcom-3rdparty-filter"
|
||||
}
|
||||
}
|
||||
}
|
||||
62
bolcom-3rdparty-filter/popup/filter.css
Normal file
62
bolcom-3rdparty-filter/popup/filter.css
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
body {
|
||||
background-color: #2e2e2e;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #fff;
|
||||
font-size: 0.9em;
|
||||
font-family: Verdana;
|
||||
}
|
||||
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 120px;
|
||||
height: 34px;
|
||||
}
|
||||
|
||||
/* Hide default HTML checkbox */
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/* The slider */
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #1a1a1a;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 26px;
|
||||
width: 54px;
|
||||
left: 4px;
|
||||
bottom: 4px;
|
||||
background-color: #ccc;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
input:checked + .slider {
|
||||
background-color: #2196F3;
|
||||
}
|
||||
|
||||
input:focus + .slider {
|
||||
box-shadow: 0 0 1px #2196F3;
|
||||
}
|
||||
|
||||
input:checked + .slider:before {
|
||||
-webkit-transform: translateX(54px);
|
||||
-ms-transform: translateX(54px);
|
||||
transform: translateX(54px);
|
||||
}
|
||||
19
bolcom-3rdparty-filter/popup/filter.html
Normal file
19
bolcom-3rdparty-filter/popup/filter.html
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="filter.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form>
|
||||
<h1>3RD Party Filter</h1>
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="toggle">
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
</form>
|
||||
|
||||
<script src="filter.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
27
bolcom-3rdparty-filter/popup/filter.js
Normal file
27
bolcom-3rdparty-filter/popup/filter.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
function saveOptions(e) {
|
||||
browser.storage.local.set({
|
||||
filter: { enabled: document.querySelector("#toggle").checked },
|
||||
});
|
||||
console.log('Tried Storing: ' + document.querySelector("#toggle").checked);
|
||||
}
|
||||
|
||||
function restoreOptions() {
|
||||
function setCurrentChoice(result) {
|
||||
console.log('Got: ' + result.filter.enabled)
|
||||
if (result.filter.enabled == true) {
|
||||
document.querySelector("#toggle").checked = true;
|
||||
} else {
|
||||
document.querySelector("#toggle").checked = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
|
||||
let getting = browser.storage.local.get("filter");
|
||||
getting.then(setCurrentChoice, onError);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", restoreOptions);
|
||||
document.querySelector("#toggle").addEventListener("click", saveOptions);
|
||||
Loading…
Add table
Add a link
Reference in a new issue