diff --git a/bolcom-3rdparty-filter/background.js b/bolcom-3rdparty-filter/background.js new file mode 100644 index 0000000..2410cea --- /dev/null +++ b/bolcom-3rdparty-filter/background.js @@ -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); \ No newline at end of file diff --git a/bolcom-3rdparty-filter/icons/icon-32.png b/bolcom-3rdparty-filter/icons/icon-32.png new file mode 100644 index 0000000..4f642e9 Binary files /dev/null and b/bolcom-3rdparty-filter/icons/icon-32.png differ diff --git a/bolcom-3rdparty-filter/icons/icon-48.png b/bolcom-3rdparty-filter/icons/icon-48.png new file mode 100644 index 0000000..ba43560 Binary files /dev/null and b/bolcom-3rdparty-filter/icons/icon-48.png differ diff --git a/bolcom-3rdparty-filter/manifest.json b/bolcom-3rdparty-filter/manifest.json new file mode 100644 index 0000000..8189156 --- /dev/null +++ b/bolcom-3rdparty-filter/manifest.json @@ -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" + } + } +} diff --git a/bolcom-3rdparty-filter/popup/filter.css b/bolcom-3rdparty-filter/popup/filter.css new file mode 100644 index 0000000..34ab1b2 --- /dev/null +++ b/bolcom-3rdparty-filter/popup/filter.css @@ -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); +} \ No newline at end of file diff --git a/bolcom-3rdparty-filter/popup/filter.html b/bolcom-3rdparty-filter/popup/filter.html new file mode 100644 index 0000000..e4e9126 --- /dev/null +++ b/bolcom-3rdparty-filter/popup/filter.html @@ -0,0 +1,19 @@ + + + + + + + + +
+

3RD Party Filter

+ +
+ + + + diff --git a/bolcom-3rdparty-filter/popup/filter.js b/bolcom-3rdparty-filter/popup/filter.js new file mode 100644 index 0000000..c6b4bb8 --- /dev/null +++ b/bolcom-3rdparty-filter/popup/filter.js @@ -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); \ No newline at end of file