diff --git a/icons/light-mode.png b/icons/light-mode.png new file mode 100644 index 0000000..77572d0 Binary files /dev/null and b/icons/light-mode.png differ diff --git a/icons/night-mode.png b/icons/night-mode.png new file mode 100644 index 0000000..d75fd97 Binary files /dev/null and b/icons/night-mode.png differ diff --git a/options.html b/options.html index 126bc84..110cee8 100644 --- a/options.html +++ b/options.html @@ -3,78 +3,100 @@ RR Adblocker Config + + + + + + + + + + + + - - - - - - - - - + .mode { + position: absolute; + right: 6px; + top: 6px; + cursor: pointer + } - + .mode:hover { + transform: scale(0.95) + } + + .mode:active { + transform: scale(0.9) + } + + .mode img { + width: 40px + } + + .light-mode { + display: none + } + + .night-mode-style { + background-color: #262626; + color: #fff + } + + .night-mode-style #save { + color: #000 + } + + .night-mode-style .saveAfter { + color: #fff + } + + .night-mode-style .info-icon { + color: #fff; + border-color: #fff + } + + .night-mode-style button { + color: #fff + } + + /*# sourceMappingURL=options.min.css.map */ + +
+ night mode +
+
+ light mode +

About

- RR Adblocker is an open-source browser addon that + RR Adblocker is an open-source browser addon that
blocks ads and trackers to make your web surfing faster and safer.
It aims at creating a safe, private internet experience and is completely free.
-
No Telemetry.
No "Anonymous" Usage Statistics.
No Donations
+
No Telemetry.
No "Anonymous" Usage Statistics.
No + Donations
Have a suggestion?
- +

Found a Bug/Issue?
Reporting Options:

- +

+ href="https://chrome.google.com/webstore/detail/rr-adblocker/chnhdkklhnokmmcklomnlcmcdbdiaemp/support" + target="_blank">

Contributions:

- + - +

@@ -317,4 +411,4 @@

About

- + \ No newline at end of file diff --git a/options.js b/options.js index cb08c7f..4e441f1 100644 --- a/options.js +++ b/options.js @@ -27,32 +27,44 @@ function save_options() { }, 750); if (useAdv) { chrome.declarativeNetRequest.updateEnabledRulesets({ - enableRulesetIds: ["advLIST"]});} + enableRulesetIds: ["advLIST"] + }); + } if (useAntiprn) { chrome.declarativeNetRequest.updateEnabledRulesets({ - enableRulesetIds: ["antiprnLIST"]});} + enableRulesetIds: ["antiprnLIST"] + }); + } if (useSusp) { chrome.declarativeNetRequest.updateEnabledRulesets({ - enableRulesetIds: ["suspLIST"]});} + enableRulesetIds: ["suspLIST"] + }); + } if (!useAdv) { chrome.declarativeNetRequest.updateEnabledRulesets({ - disableRulesetIds: ["advLIST"]});} + disableRulesetIds: ["advLIST"] + }); + } if (!useAntiprn) { chrome.declarativeNetRequest.updateEnabledRulesets({ - disableRulesetIds: ["antiprnLIST"]});} + disableRulesetIds: ["antiprnLIST"] + }); + } if (!useSusp) { chrome.declarativeNetRequest.updateEnabledRulesets({ - disableRulesetIds: ["suspLIST"]});} + disableRulesetIds: ["suspLIST"] + }); + } checkStateChanged = false; } advFilter.onclick = function () { - if (advFilter.checked){modal.style.display = "block";} + if (advFilter.checked) { modal.style.display = "block"; } } var settings = document.querySelectorAll("input[type='checkbox']"); settings.forEach(element => { - element.onchange = () =>{ + element.onchange = () => { Savebtn.classList.remove('saveBefore'); Savebtn.classList.add('saveAfter'); } @@ -65,115 +77,127 @@ function restore_options() { suspFilter.checked = items.suspStat; if (items.advStat) { chrome.declarativeNetRequest.updateEnabledRulesets({ - enableRulesetIds: ["advLIST"]});} + enableRulesetIds: ["advLIST"] + }); + } if (items.antiPrnStat) { chrome.declarativeNetRequest.updateEnabledRulesets({ - enableRulesetIds: ["antiprnLIST"]});} + enableRulesetIds: ["antiprnLIST"] + }); + } if (items.suspStat) { chrome.declarativeNetRequest.updateEnabledRulesets({ - enableRulesetIds: ["suspLIST"]});} + enableRulesetIds: ["suspLIST"] + }); + } if (!items.advStat) { chrome.declarativeNetRequest.updateEnabledRulesets({ - disableRulesetIds: ["advLIST"]});} + disableRulesetIds: ["advLIST"] + }); + } if (!items.antiPrnStat) { chrome.declarativeNetRequest.updateEnabledRulesets({ - disableRulesetIds: ["antiprnLIST"]});} + disableRulesetIds: ["antiprnLIST"] + }); + } if (!items.suspStat) { chrome.declarativeNetRequest.updateEnabledRulesets({ - disableRulesetIds: ["suspLIST"]});} + disableRulesetIds: ["suspLIST"] + }); + } }); - + } span.onclick = function () { modal.style.display = "none"; } window.onclick = function (event) { - if (event.target == modal) {modal.style.display = "none";} + if (event.target == modal) { modal.style.display = "none"; } } -if(updtBtn){ - updtBtn.onclick = function() { +if (updtBtn) { + updtBtn.onclick = function () { var updtUrl = "https://raw.githubusercontent.com/Rutuj-Runwal/RR-Adblocker/main/patch.txt"; - try{ + try { fetch(updtUrl) - .then(response => response.text()) - .then(function(text){ - let urlPatchDt = text.split("\n"); - let patchRules = []; - let patchRulesId = []; - let id=4950; - if(urlPatchDt.length>2){ - for (let i = 2; i < urlPatchDt.length; i++) { - patchRulesId.push(id); - if(urlPatchDt[i].includes("U: ")){ - var data = urlPatchDt[i].split(' '); - var blockOrAllow = data[2].trim()==="A"?"allow":"block"; - var priorityBorA = blockOrAllow==="allow"?2:1; - patchRules.push({ - "id": id++, - "priority": priorityBorA, - "action": { - "type": blockOrAllow, - }, - "condition": { - "urlFilter": "||"+data[1].trim()+"^", - "resourceTypes": [ - "main_frame", - "sub_frame", - "script", - "xmlhttprequest", - "ping", - "csp_report", - "stylesheet", - "media", - "websocket", - "image", - "webtransport", - "webbundle", - "other" - ] + .then(response => response.text()) + .then(function (text) { + let urlPatchDt = text.split("\n"); + let patchRules = []; + let patchRulesId = []; + let id = 4950; + if (urlPatchDt.length > 2) { + for (let i = 2; i < urlPatchDt.length; i++) { + patchRulesId.push(id); + if (urlPatchDt[i].includes("U: ")) { + var data = urlPatchDt[i].split(' '); + var blockOrAllow = data[2].trim() === "A" ? "allow" : "block"; + var priorityBorA = blockOrAllow === "allow" ? 2 : 1; + patchRules.push({ + "id": id++, + "priority": priorityBorA, + "action": { + "type": blockOrAllow, + }, + "condition": { + "urlFilter": "||" + data[1].trim() + "^", + "resourceTypes": [ + "main_frame", + "sub_frame", + "script", + "xmlhttprequest", + "ping", + "csp_report", + "stylesheet", + "media", + "websocket", + "image", + "webtransport", + "webbundle", + "other" + ] + } + }) } - }) - } - else if (urlPatchDt[i].includes("R: ")) { - console.log(urlPatchDt[i].split(' ')[1]); - patchRules.push({ - "id": id++, - "priority": 1, - "action": { - "type": "block", - }, - "condition": { - "regexFilter": urlPatchDt[i].split(' ')[1].trim(), - "resourceTypes": [ - "main_frame", - "sub_frame", - "script", - "xmlhttprequest", - "ping", - "csp_report", - "stylesheet", - "media", - "websocket", - "image", - "webtransport", - "webbundle", - "other" - ] + else if (urlPatchDt[i].includes("R: ")) { + console.log(urlPatchDt[i].split(' ')[1]); + patchRules.push({ + "id": id++, + "priority": 1, + "action": { + "type": "block", + }, + "condition": { + "regexFilter": urlPatchDt[i].split(' ')[1].trim(), + "resourceTypes": [ + "main_frame", + "sub_frame", + "script", + "xmlhttprequest", + "ping", + "csp_report", + "stylesheet", + "media", + "websocket", + "image", + "webtransport", + "webbundle", + "other" + ] + } + }) } - }) + } + patchRulesId = patchRulesId.slice(0, patchRulesId.length - 1); + chrome.declarativeNetRequest.updateDynamicRules({ + addRules: patchRules, + removeRuleIds: patchRulesId, + }); } - } - patchRulesId = patchRulesId.slice(0,patchRulesId.length-1); - chrome.declarativeNetRequest.updateDynamicRules({ - addRules: patchRules, - removeRuleIds: patchRulesId, - }); - } - console.log(patchRules); - console.log(patchRulesId); - alert("Done! Latest filters have been applied. If you still face issues with certain website report the Bug/Issue"); - }).catch(function(err){console.log(err);alert("Failed to get updates! Ensure you have a stable network connection.")}); - }catch(err){ + console.log(patchRules); + console.log(patchRulesId); + alert("Done! Latest filters have been applied. If you still face issues with certain website report the Bug/Issue"); + }).catch(function (err) { console.log(err); alert("Failed to get updates! Ensure you have a stable network connection.") }); + } catch (err) { alert("Failed to get updates! Ensure you have a stable network connection."); } } @@ -194,4 +218,33 @@ window.addEventListener('beforeunload', function (event) { event.preventDefault(); event.returnValue = ''; } -}); +}) + +window.onload = () => { + let nightMode = document.getElementsByClassName("mode")[0] + let lightMode = document.getElementsByClassName("mode")[1] + nightMode.onclick = () => { + toggleMode() + } + lightMode.onclick = () => { + toggleMode() + } +} + +const toggleMode = () => { + let nightMode = document.getElementsByClassName("mode")[0] + let lightMode = document.getElementsByClassName("light-mode")[0] + + if (nightMode.style.display == "") { + nightMode.style.display = "block" + } else { + nightMode.style.display = "" + } + + if (lightMode.style.display == "") { + lightMode.style.display = "block" + } else { + lightMode.style.display = "" + } + document.getElementsByTagName("body")[0].classList.toggle("night-mode-style") +}