diff options
author | Austin Huang <im@austinhuang.me> | 2020-10-23 19:15:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-23 19:15:38 -0400 |
commit | c66891384238aa7f88956034e21b663c01e93eaa (patch) | |
tree | 4c42861245b20c78a70afdacff86c61b7d01397c /pages | |
parent | Fixes #51 & fixes #52 - `/tweets` redirects & popup styling (diff) | |
parent | Merge pull request #106 from MichipX3/patch-1 (diff) | |
download | libredirect-c66891384238aa7f88956034e21b663c01e93eaa.zip |
Merge pull request #2 from SimonBrazell/master
force update
Diffstat (limited to 'pages')
-rw-r--r-- | pages/options/options.html | 617 | ||||
-rw-r--r-- | pages/options/options.js | 424 | ||||
-rw-r--r-- | pages/popup/open.svg | 5 | ||||
-rw-r--r-- | pages/popup/popup.html | 274 | ||||
-rw-r--r-- | pages/popup/popup.js | 115 | ||||
-rw-r--r-- | pages/styles.css | 297 |
6 files changed, 1155 insertions, 577 deletions
diff --git a/pages/options/options.html b/pages/options/options.html index 35ef7a43..6641e5c4 100644 --- a/pages/options/options.html +++ b/pages/options/options.html @@ -1,183 +1,448 @@ <!DOCTYPE html> <html> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <title></title> + <link href="../styles.css" rel="stylesheet" /> + <title>Privacy Redirect Options</title> + </head> -<head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <title></title> - <link href="../styles.css" rel="stylesheet"> - <title>Privacy Redirect Options</title> -</head> + <body> + <div class="tab"> + <button + class="tablinks" + id="general-tab" + data-localise="__MSG_generalTab__" + > + General + </button> + <button + class="tablinks" + id="advanced-tab" + data-localise="__MSG_advancedTab__" + > + Advanced + </button> + <button + class="tablinks" + id="exceptions-tab" + data-localise="__MSG_exceptionsTab__" + > + Exceptions + </button> + </div> -<body> + <div id="general" class="tabcontent"> + <section class="settings-block"> + <table class="option" aria-label="Toggle Nitter redirects"> + <tbody> + <tr> + <td> + <h1 data-localise="__MSG_disableNitter__">Nitter Redirects</h1> + </td> + <td> + <input + aria-hidden="true" + id="disable-nitter" + type="checkbox" + checked + /> + <label for="disable-nitter" class="checkbox-label"></label> + </td> + </tr> + </tbody> + </table> + </section> + <section class="settings-block"> + <table class="option" aria-label="Toggle Invidious redirects"> + <tbody> + <tr> + <td> + <h1 data-localise="__MSG_disableInvidious__"> + Invidious Redirects + </h1> + </td> + <td> + <input + aria-hidden="true" + id="disable-invidious" + type="checkbox" + checked + /> + <label for="disable-invidious" class="checkbox-label"> </label> + </td> + </tr> + </tbody> + </table> + </section> + <section class="settings-block"> + <table class="option" aria-label="Toggle Bibliogram redirects"> + <tbody> + <tr> + <td> + <h1 data-localise="__MSG_disableBibliogram__"> + Bibliogram Redirects + </h1> + </td> + <td> + <input + aria-hidden="true" + id="disable-bibliogram" + type="checkbox" + checked + /> + <label for="disable-bibliogram" class="checkbox-label"> </label> + </td> + </tr> + </tbody> + </table> + </section> + <section class="settings-block"> + <table class="option" aria-label="Toggle OpenStreetMap redirects"> + <tbody> + <tr> + <td> + <h1 data-localise="__MSG_disableOsm__"> + OpenStreetMap Redirects + </h1> + </td> + <td> + <input + aria-hidden="true" + id="disable-osm" + type="checkbox" + checked + /> + <label for="disable-osm" class="checkbox-label"> </label> + </td> + </tr> + </tbody> + </table> + </section> + <section class="settings-block"> + <h1 data-localise="__MSG_nitterInstance__">Nitter Instance</h1> + <div class="autocomplete"> + <input + id="nitter-instance" + type="url" + name="nitter-instance" + placeholder="Random instance (none selected)" + /> + </div> + </section> + <section class="settings-block"> + <h1 data-localise="__MSG_invidiousInstance__">Invidious Instance</h1> + <div class="autocomplete"> + <input + id="invidious-instance" + type="url" + placeholder="Random instance (none selected)" + /> + </div> + </section> + <section class="settings-block"> + <h1 data-localise="__MSG_bibliogramInstance__">Bibliogram Instance</h1> + <div class="autocomplete"> + <input + id="bibliogram-instance" + type="url" + placeholder="Random instance (none selected)" + /> + </div> + </section> + <section class="settings-block"> + <h1 data-localise="__MSG_osmInstance__">OpenStreetMap Instance</h1> + <div class="autocomplete"> + <input + id="osm-instance" + type="url" + placeholder="https://openstreetmap.org" + /> + </div> + </section> + <section class="settings-block"> + <h1 data-localise="__MSG_theme__">Theme</h1> + <select id="theme"> + <option value="">System</option> + <option value="light-theme">Light</option> + <option value="dark-theme">Dark</option> + </select> + </section> + </div> - <div class="tab"> - <button class="tablinks" id="general-tab">General</button> - <button class="tablinks" id="advanced-tab">Advanced</button> - <button class="tablinks" id="whitelist-tab">Whitelist</button> - </div> + <div id="advanced" class="tabcontent"> + <section class="settings-block"> + <table + class="option" + aria-label="Always proxy videos through Invidious" + > + <tbody> + <tr> + <td> + <h1 data-localise="__MSG_alwaysProxy__"> + Always proxy videos through Invidious + </h1> + </td> + <td> + <input + aria-hidden="true" + id="always-proxy" + type="checkbox" + checked + /> + <label for="always-proxy" class="checkbox-label"> </label> + </td> + </tr> + </tbody> + </table> + </section> + <section class="settings-block"> + <table + class="option" + aria-label="Only redirect embedded video to Invidious" + > + <tbody> + <tr> + <td> + <h1 data-localise="__MSG_onlyEmbeddedVideo__"> + Only redirect embedded video to Invidious + </h1> + </td> + <td> + <input + aria-hidden="true" + id="only-embed" + type="checkbox" + checked + /> + <label for="only-embed" class="checkbox-label"> </label> + </td> + </tr> + </tbody> + </table> + </section> + <section class="settings-block"> + <h1 data-localise="__MSG_videoQuality__">Invidious Video Quality</h1> + <select id="video-quality"> + <option value="">Default</option> + <option value="hd720">720p</option> + <option value="medium">480p</option> + <option value="dash">DASH (Dynamic Adaptive Streaming over HTTP)</option> + </option> + </select> + </section> + <section class="settings-block"> + <table class="option" aria-label="Invidious dark mode aways on"> + <tbody> + <tr> + <td> + <h1 data-localise="__MSG_invidiousDarkMode__"> + Invidious dark mode always on + </h1> + </td> + <td> + <input + aria-hidden="true" + id="invidious-dark-mode" + type="checkbox" + checked + /> + <label for="invidious-dark-mode" class="checkbox-label"> + </label> + </td> + </tr> + </tbody> + </table> + </section> + <section class="settings-block"> + <h1 data-localise="__MSG_invidiousVolume__"> + Invidious Volume + </h1> + <input + id="invidious-volume" + name="invidious-volume" + type="range" + min="0" + max="100" + step="1" + /><span id="volume-value"></span> + </section> + <section class="settings-block"> + <h1 data-localise="__MSG_invidiousPlayerStyle__"> + Invidious Player Style + </h1> + <select id="invidious-player-style"> + <option value="">Invidious</option> + <option value="youtube">YouTube</option> + </select> + </section> + <section class="settings-block"> + <h1 data-localise="__MSG_invidiousSubtitles__"> + Invidious Subtitles - language codes (comma-separated) + </h1> + <input + id="invidious-subtitles" + name="invidious-subtitles" + type="text" + /> + </section> + <section class="settings-block"> + <table + class="option" + aria-label="Invidious automatically play video on load" + > + <tbody> + <tr> + <td> + <h1 data-localise="__MSG_invidiousAutoplay__"> + Invidious automatically play video on load + </h1> + </td> + <td> + <input + aria-hidden="true" + id="invidious-autoplay" + type="checkbox" + checked + /> + <label for="invidious-autoplay" class="checkbox-label"> </label> + </td> + </tr> + </tbody> + </table> + </section> + <section class="settings-block"> + <table class="option" aria-label="Persist Invidious preferences"> + <tbody> + <tr> + <td> + <h1 data-localise="__MSG_persistInvidiousPrefs__"> + Persist Invidious preferences (as cookie) + </h1> + </td> + <td> + <input + aria-hidden="true" + id="persist-invidious-prefs" + type="checkbox" + checked + /> + <label for="persist-invidious-prefs" class="checkbox-label"> + </label> + </td> + </tr> + </tbody> + </table> + </section> + <section class="settings-block"> + <table + class="option" + aria-label="Proactively remove Twitter service worker" + > + <tbody> + <tr> + <td> + <h1 data-localise="__MSG_removeTwitterSW__"> + Proactively remove Twitter service worker + </h1> + </td> + <td> + <input + aria-hidden="true" + id="remove-twitter-sw" + type="checkbox" + checked + /> + <label for="remove-twitter-sw" class="checkbox-label"> </label> + </td> + </tr> + </tbody> + </table> + </section> + </div> - <div id="general" class="tabcontent"> - <section class="options settings_block"> - <div class="onoffswitch switch" aria-label="Toggle Nitter redirects"> - <h1>Nitter Redirects</h1> - <input aria-hidden="true" id="disable-nitter" type="checkbox" checked> - <label for="disable-nitter" class="checkbox-label"> - </label> - </div> - </section> + <div id="exceptions" class="tabcontent"> + <section class="settings-block"> + <p data-localise="__MSG_exceptionsDescriptionP1__"> + Enter a URL or Regular Expression to be excluded from redirects. + </p> + <p data-localise="__MSG_exceptionsDescriptionP2__"> + All requests for or initiating from a URL that matches your exception + will be excluded from redirects. + </p> + <p data-localise="__MSG_exceptionsDescriptionP3__"> + Note - Supports JavaScript regular expressions, excluding the + enclosing forward slashes. + </p> + </section> + <section class="settings-block"> + <table class="exceptions option"> + <tbody> + <tr> + <td> + <h1 data-localise="__MSG_addException__">Add Exception</h1> + </td> + </tr> + <tr> + <td> + <input + id="new-exceptions-item" + type="text" + placeholder="URL or RegExp" + /> + </td> + <td> + <input type="radio" id="url" name="type" value="URL" checked /> + <label class="radio" for="url">URL</label> + <input type="radio" id="regExp" name="type" value="RegExp" /> + <label class="radio" for="regExp">RegExp</label> + </td> + <td> + <button id="add-to-exceptions"> + <svg + xmlns="http://www.w3.org/2000/svg" + width="512" + height="512" + viewBox="0 0 512 512" + > + <line + x1="256" + y1="112" + x2="256" + y2="400" + style=" + fill: none; + stroke: #fff; + stroke-linecap: round; + stroke-linejoin: round; + stroke-width: 32px; + " + /> + <line + x1="400" + y1="256" + x2="112" + y2="256" + style=" + fill: none; + stroke: #fff; + stroke-linecap: round; + stroke-linejoin: round; + stroke-width: 32px; + " + /> + </svg> + </button> + </td> + </tr> + </tbody> + </table> + </section> + <ul id="exceptions-items"></ul> + </div> - <section class="options settings_block"> - <div class="onoffswitch switch" aria-label="Toggle Invidious redirects"> - <h1>Invidious Redirects</h1> - <input aria-hidden="true" id="disable-invidious" type="checkbox" checked> - <label for="disable-invidious" class="checkbox-label"> - </label> - </div> - </section> - - <section class="options settings_block"> - <div class="onoffswitch switch" aria-label="Toggle Bibliogram redirects"> - <h1>Bibliogram Redirects</h1> - <input aria-hidden="true" id="disable-bibliogram" type="checkbox" checked> - <label for="disable-bibliogram" class="checkbox-label"> - </label> - </div> - </section> - - <section class="options settings_block"> - <div class="onoffswitch switch" aria-label="Toggle OpenStreetMap redirects"> - <h1>OpenStreetMap Redirects</h1> - <input aria-hidden="true" id="disable-osm" type="checkbox" checked> - <label for="disable-osm" class="checkbox-label"> - </label> - </div> - </section> - - <section class="options settings_block"> - <h1>Nitter Instance</h1> - <input id="nitter-instance" list="nitter-instance-list" type="url" placeholder="https://nitter.net"> - <datalist id="nitter-instance-list"> - <option value="https://nitter.net"> - <option value="https://nitter.snopyta.org"> - <option value="https://nitter.42l.fr"> - <option value="https://nitter.nixnet.xyz"> - <option value="https://nitter.13ad.de"> - <option value="https://tw.openalgeria.org"> - <option value="https://nitter.pussthecat.org"> - <option value="https://nitter.mastodont.cat"> - <option value="https://nitter.dark.fail"> - <option value="https://nitter.tedomum.net"> - <option value="https://t.maisputain.ovh"> - <option value="http://3nzoldnxplag42gqjs23xvghtzf6t6yzssrtytnntc6ppc7xxuoneoad.onion"> - <option value="http://nitter.l4qlywnpwqsluw65ts7md3khrivpirse744un3x7mlskqauz5pyuzgqd.onion"> - <option value="http://3nzoldnxplag42gqjs23xvghtzf6t6yzssrtytnntc6ppc7xxuoneoad.onion"> - </datalist> - <h1>Invidious Instance</h1> - <input id="invidious-instance" list="invidious-instances-list" type="url" placeholder="https://invidio.us"> - <datalist id="invidious-instances-list"> - <option value="https://invidio.us"> - <option value="https://invidious.snopyta.org"> - <option value="https://invidiou.sh"> - <option value="https://yewtu.be"> - <option value="https://yt.maisputain.ovh"> - <option value="https://invidious.toot.koeln"> - <option value="https://invidious.ggc-project.de"> - <option value="https://invidious.toot.koeln"> - <option value="http://kgg2m7yk5aybusll.onion"> - <option value="http://axqzx4s6s54s32yentfqojs3x5i7faxza6xo3ehd4bzzsg2ii4fv2iid.onion"> - <option value="http://fz253lmuao3strwbfbmx46yu7acac2jz27iwtorgmbqlkurlclmancad.onion"> - <option value="http://qklhadlycap4cnod.onion"> - <option value="http://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion"> - <option value="http://mfqczy4mysscub2s.onion"> - </datalist> - <h1>Bibliogram Instance</h1> - <input id="bibliogram-instance" list="bibliogram-instance-list" type="url" placeholder="https://bibliogram.art"> - <datalist id="bibliogram-instance-list"> - <option value="https://bibliogram.art"> - <option value="https://bibliogram.snopyta.org"> - <option value="https://bibliogram.pussthecat.org"> - <option value="https://insta.maisputain.ovh"> - <option value="https://bibliogram.nixnet.services"> - </datalist> - <h1>OpenStreetMap Instance</h1> - <input id="osm-instance" list="osm-instance-list" type="url" placeholder="https://openstreetmap.org"> - <datalist id="osm-instance-list"> - <option value="https://openstreetmap.org"> - </datalist> - </section> - </div> - - <div id="advanced" class="tabcontent"> - <section class="options settings_block"> - <div class="onoffswitch switch" aria-label="Always proxy videos through Invidious"> - <h1>Always proxy videos through Invidious</h1> - <input aria-hidden="true" id="always-proxy" type="checkbox" checked> - <label for="always-proxy" class="checkbox-label"> - </label> - </div> - </section> - - <section class="options settings_block"> - <div class="onoffswitch switch" aria-label="Only redirect embedded video to Invidious"> - <h1>Only redirect embedded video to Invidious</h1> - <input aria-hidden="true" id="only-embed" type="checkbox" checked> - <label for="only-embed" class="checkbox-label"> - </label> - </div> - </section> - - <section class="options settings_block"> - <h1>Invidious Video Quality</h1> - <select id="video-quality"> - <option value="">Default</option> - <option value="hd720">720p</option> - <option value="medium">480p</option> - <option value="dash">DASH (Dynamic Adaptive Streaming over HTTP)</option> - </select> - </section> - - <section class="options settings_block"> - <div class="onoffswitch switch" aria-label="Invidious dark mode aways on"> - <h1>Invidious dark mode always on</h1> - <input aria-hidden="true" id="invidious-dark-mode" type="checkbox" checked> - <label for="invidious-dark-mode" class="checkbox-label"> - </label> - </div> - </section> - - <section class="options settings_block"> - <div class="onoffswitch switch" aria-label="Persist Invidious preferences"> - <h1>Persist Invidious preferences (as cookie)</h1> - <input aria-hidden="true" id="persist-invidious-prefs" type="checkbox" checked> - <label for="persist-invidious-prefs" class="checkbox-label"> - </label> - </div> - </section> - - <section class="options settings_block"> - <div class="onoffswitch switch" aria-label="Proactively remove Twitter service worker"> - <h1>Proactively remove Twitter service worker</h1> - <input aria-hidden="true" id="remove-twitter-sw" type="checkbox" checked> - <label for="remove-twitter-sw" class="checkbox-label"> - </label> - </div> - </section> - </div> - - <div id="whitelist" class="tabcontent"> - <section class="options settings_block"> - <h1>Whitelisted Sites</h1> - <div class="whitelist"> - <input id="new-whitelist-item" type="text" placeholder="URL (RegExp accepted)"> - <button id="add-to-whitelist">Add to Whitelist</button> - </div> - </section> - <ul id="whitelist-items"></ul> - </div> - - <script src="./options.js"></script> - -</body> - -</html> \ No newline at end of file + <script src="./options.js"></script> + <script src="../../assets/javascript/localise.js"></script> + </body> +</html> diff --git a/pages/options/options.js b/pages/options/options.js index 5e25a495..8149be7b 100644 --- a/pages/options/options.js +++ b/pages/options/options.js @@ -1,130 +1,213 @@ -'use strict'; - -let nitterInstance = document.getElementById('nitter-instance'); -let invidiousInstance = document.getElementById('invidious-instance'); -let bibliogramInstance = document.getElementById('bibliogram-instance'); -let osmInstance = document.getElementById('osm-instance'); -let disableNitter = document.getElementById('disable-nitter'); -let disableInvidious = document.getElementById('disable-invidious'); -let disableBibliogram = document.getElementById('disable-bibliogram'); -let disableOsm = document.getElementById('disable-osm'); -let alwaysProxy = document.getElementById('always-proxy'); -let onlyEmbeddedVideo = document.getElementById('only-embed'); -let videoQuality = document.getElementById('video-quality'); -let removeTwitterSW = document.getElementById('remove-twitter-sw'); -let invidiousDarkMode = document.getElementById('invidious-dark-mode'); -let persistInvidiousPrefs = document.getElementById('persist-invidious-prefs'); -let whitelist; +"use strict"; + +const nitterInstances = [ + "https://nitter.net", + "https://nitter.snopyta.org", + "https://nitter.42l.fr", + "https://nitter.nixnet.services", + "https://nitter.13ad.de", + "https://nitter.pussthecat.org", + "https://nitter.mastodont.cat", + "https://nitter.dark.fail", + "https://nitter.tedomum.net", + "https://t.maisputain.ovh", + "http://3nzoldnxplag42gqjs23xvghtzf6t6yzssrtytnntc6ppc7xxuoneoad.onion", + "http://nitter.l4qlywnpwqsluw65ts7md3khrivpirse744un3x7mlskqauz5pyuzgqd.onion", +]; +const invidiousInstances = [ + "https://invidious.snopyta.org", + "https://yewtu.be", + "https://invidious.ggc-project.de", + "https://invidious.13ad.de", + "https://invidious.xyz", + "https://invidious.toot.koeln", + "https://invidious.site", + "https://invidiou.site", + "https://invidious.fdn.fr", + "https://watch.nettohikari.com", + "https://yt.iswleuven.be", + "https://yt.maisputain.ovh", + "http://kgg2m7yk5aybusll.onion", + "http://axqzx4s6s54s32yentfqojs3x5i7faxza6xo3ehd4bzzsg2ii4fv2iid.onion", + "http://fz253lmuao3strwbfbmx46yu7acac2jz27iwtorgmbqlkurlclmancad.onion", + "http://qklhadlycap4cnod.onion", + "http://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion", + "http://mfqczy4mysscub2s.onion", + "http://4l2dgddgsrkf2ous66i6seeyi6etzfgrue332grh2n7madpwopotugyd.onion", +]; +const bibliogramInstances = [ + "https://bibliogram.art", + "https://bibliogram.snopyta.org", + "https://bibliogram.pussthecat.org", + "https://bibliogram.nixnet.services", + "https://bibliogram.hamster.dance", + "https://insta.maisputain.ovh", + "https://bibliogram.ggc-project.de", +]; +const osmInstances = ["https://openstreetmap.org"]; +const autocompletes = [ + { id: "nitter-instance", instances: nitterInstances }, + { id: "invidious-instance", instances: invidiousInstances }, + { id: "bibliogram-instance", instances: bibliogramInstances }, + { id: "osm-instance", instances: osmInstances }, +]; + +let nitterInstance = document.getElementById("nitter-instance"); +let invidiousInstance = document.getElementById("invidious-instance"); +let bibliogramInstance = document.getElementById("bibliogram-instance"); +let osmInstance = document.getElementById("osm-instance"); +let disableNitter = document.getElementById("disable-nitter"); +let disableInvidious = document.getElementById("disable-invidious"); +let disableBibliogram = document.getElementById("disable-bibliogram"); +let disableOsm = document.getElementById("disable-osm"); +let alwaysProxy = document.getElementById("always-proxy"); +let onlyEmbeddedVideo = document.getElementById("only-embed"); +let videoQuality = document.getElementById("video-quality"); +let removeTwitterSW = document.getElementById("remove-twitter-sw"); +let invidiousDarkMode = document.getElementById("invidious-dark-mode"); +let persistInvidiousPrefs = document.getElementById("persist-invidious-prefs"); +let invidiousVolume = document.getElementById("invidious-volume"); +let invidiousPlayerStyle = document.getElementById("invidious-player-style"); +let invidiousSubtitles = document.getElementById("invidious-subtitles"); +let invidiousAutoplay = document.getElementById("invidious-autoplay"); +let theme = document.getElementById("theme"); +let exceptions; window.browser = window.browser || window.chrome; -function prependWhitelistItem(item, index) { - const li = document.createElement('li'); +function prependExceptionsItem(item, index) { + const li = document.createElement("li"); li.appendChild(document.createTextNode(item.toString())); - const button = document.createElement('button'); - button.appendChild(document.createTextNode('X')); - button.addEventListener('click', () => { - li.remove(); - whitelist.splice(index, 1); + const button = document.createElement("button"); + li.appendChild(button); + document.getElementById("exceptions-items").prepend(li); + const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 512 512'> + <line x1='368' y1='368' x2='144' y2='144' + style='fill:none;stroke:#FFF;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px' /> + <line x1='368' y1='144' x2='144' y2='368' + style='fill:none;stroke:#FFF;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px' /> + </svg>`; + button.innerHTML = svg; + button.addEventListener("click", () => { + exceptions.splice(index, 1); browser.storage.sync.set({ - whitelist: whitelist + exceptions: exceptions, }); + li.remove(); }); - li.appendChild(button); - document.getElementById('whitelist-items').prepend(li); } browser.storage.sync.get( [ - 'nitterInstance', - 'invidiousInstance', - 'bibliogramInstance', - 'osmInstance', - 'disableNitter', - 'disableInvidious', - 'disableBibliogram', - 'disableOsm', - 'alwaysProxy', - 'onlyEmbeddedVideo', - 'videoQuality', - 'removeTwitterSW', - 'whitelist', - 'invidiousDarkMode', - 'persistInvidiousPrefs' + "nitterInstance", + "invidiousInstance", + "bibliogramInstance", + "osmInstance", + "disableNitter", + "disableInvidious", + "disableBibliogram", + "disableOsm", + "alwaysProxy", + "onlyEmbeddedVideo", + "videoQuality", + "removeTwitterSW", + "invidiousDarkMode", + "persistInvidiousPrefs", + "invidiousVolume", + "invidiousPlayerStyle", + "invidiousSubtitles", + "invidiousAutoplay", + "exceptions", + "theme", ], - result => { - nitterInstance.value = result.nitterInstance || ''; - invidiousInstance.value = result.invidiousInstance || ''; - bibliogramInstance.value = result.bibliogramInstance || ''; - osmInstance.value = result.osmInstance || ''; + (result) => { + theme.value = result.theme || ""; + if (result.theme) document.body.classList.add(result.theme); + nitterInstance.value = result.nitterInstance || ""; + invidiousInstance.value = result.invidiousInstance || ""; + bibliogramInstance.value = result.bibliogramInstance || ""; + osmInstance.value = result.osmInstance || ""; disableNitter.checked = !result.disableNitter; disableInvidious.checked = !result.disableInvidious; disableBibliogram.checked = !result.disableBibliogram; disableOsm.checked = !result.disableOsm; alwaysProxy.checked = result.alwaysProxy; onlyEmbeddedVideo.checked = result.onlyEmbeddedVideo; - videoQuality.value = result.videoQuality || ''; + videoQuality.value = result.videoQuality || ""; removeTwitterSW.checked = !result.removeTwitterSW; invidiousDarkMode.checked = result.invidiousDarkMode; persistInvidiousPrefs.checked = result.persistInvidiousPrefs; - whitelist = result.whitelist || []; - whitelist.forEach(prependWhitelistItem); + exceptions = result.exceptions || []; + exceptions.forEach(prependExceptionsItem); + invidiousVolume.value = result.invidiousVolume; + document.querySelector("#volume-value").textContent = result.invidiousVolume + ? `${result.invidiousVolume}%` + : " - "; + invidiousPlayerStyle.value = result.invidiousPlayerStyle || ""; + invidiousSubtitles.value = result.invidiousSubtitles || ""; + invidiousAutoplay.checked = result.invidiousAutoplay; } ); function openTab(tab, event) { let i, tabcontent, tablinks; - tabcontent = document.getElementsByClassName('tabcontent'); + tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { - tabcontent[i].style.display = 'none'; + tabcontent[i].style.display = "none"; } - tablinks = document.getElementsByClassName('tablinks'); + tablinks = document.getElementsByClassName("tablinks"); for (i = 0; i < tablinks.length; i++) { - tablinks[i].className = tablinks[i].className.replace(' active', ''); + tablinks[i].className = tablinks[i].className.replace(" active", ""); } - document.getElementById(tab).style.display = 'block'; - event.currentTarget.className += ' active'; + document.getElementById(tab).style.display = "block"; + event.currentTarget.className += " active"; } -document.getElementById('general-tab').addEventListener( - 'click', openTab.bind(null, 'general') -); -document.getElementById('advanced-tab').addEventListener( - 'click', openTab.bind(null, 'advanced') -); -document.getElementById('whitelist-tab').addEventListener( - 'click', openTab.bind(null, 'whitelist') -); +document + .getElementById("general-tab") + .addEventListener("click", openTab.bind(null, "general")); +document + .getElementById("advanced-tab") + .addEventListener("click", openTab.bind(null, "advanced")); +document + .getElementById("exceptions-tab") + .addEventListener("click", openTab.bind(null, "exceptions")); -document.getElementById('general-tab').click(); +document.getElementById("general-tab").click(); -function addToWhitelist() { - const input = document.getElementById('new-whitelist-item'); +function addToExceptions() { + const input = document.getElementById("new-exceptions-item"); + const type = document.querySelector('input[name="type"]:checked').value; if (input.value) { try { + let value = input.value; new RegExp(input.value); - const index = whitelist.push(input.value); - prependWhitelistItem(input.value, index); + if (type === "URL") { + value = value.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"); + } + exceptions.push(value); browser.storage.sync.set({ - whitelist: whitelist + exceptions: exceptions, }); - input.value = ''; + prependExceptionsItem(value, exceptions.indexOf(value)); + input.value = ""; } catch (error) { - input.setCustomValidity('Invalid RegExp'); + input.setCustomValidity("Invalid RegExp"); } } else { - input.setCustomValidity('Invalid RegExp'); + input.setCustomValidity("Invalid RegExp"); } } -document.getElementById('add-to-whitelist').addEventListener( - 'click', addToWhitelist -); +document + .getElementById("add-to-exceptions") + .addEventListener("click", addToExceptions); function debounce(func, wait, immediate) { let timeout; return () => { - let context = this, args = arguments; + let context = this, + args = arguments; let later = () => { timeout = null; if (!immediate) func.apply(context, args); @@ -134,100 +217,239 @@ function debounce(func, wait, immediate) { timeout = setTimeout(later, wait); if (callNow) func.apply(context, args); }; -}; +} function parseURL(urlString) { if (urlString) { try { const url = new URL(urlString); if (url.username && url.password) { - return `${url.protocol}//${url.username}:${url.password}@${url.host}` + return `${url.protocol}//${url.username}:${url.password}@${url.host}`; } else { return url.origin; } } catch (error) { console.log(error); - return ''; + return ""; } } else { - return ''; + return ""; } } let nitterInstanceChange = debounce(() => { if (nitterInstance.checkValidity()) { browser.storage.sync.set({ - nitterInstance: parseURL(nitterInstance.value) + nitterInstance: parseURL(nitterInstance.value), }); } }, 500); -nitterInstance.addEventListener('input', nitterInstanceChange); +nitterInstance.addEventListener("input", nitterInstanceChange); let invidiousInstanceChange = debounce(() => { if (invidiousInstance.checkValidity()) { browser.storage.sync.set({ - invidiousInstance: parseURL(invidiousInstance.value) + invidiousInstance: parseURL(invidiousInstance.value), }); } }, 500); -invidiousInstance.addEventListener('input', invidiousInstanceChange); +invidiousInstance.addEventListener("input", invidiousInstanceChange); let bibliogramInstanceChange = debounce(() => { if (bibliogramInstance.checkValidity()) { browser.storage.sync.set({ - bibliogramInstance: parseURL(bibliogramInstance.value) + bibliogramInstance: parseURL(bibliogramInstance.value), }); } }, 500); -bibliogramInstance.addEventListener('input', bibliogramInstanceChange); +bibliogramInstance.addEventListener("input", bibliogramInstanceChange); let osmInstanceChange = debounce(() => { if (osmInstance.checkValidity()) { browser.storage.sync.set({ - osmInstance: parseURL(osmInstance.value) + osmInstance: parseURL(osmInstance.value), }); } }, 500); -osmInstance.addEventListener('input', osmInstanceChange); +osmInstance.addEventListener("input", osmInstanceChange); -disableNitter.addEventListener('change', event => { +disableNitter.addEventListener("change", (event) => { browser.storage.sync.set({ disableNitter: !event.target.checked }); }); -disableInvidious.addEventListener('change', event => { +disableInvidious.addEventListener("change", (event) => { browser.storage.sync.set({ disableInvidious: !event.target.checked }); }); -disableBibliogram.addEventListener('change', event => { +disableBibliogram.addEventListener("change", (event) => { browser.storage.sync.set({ disableBibliogram: !event.target.checked }); }); -disableOsm.addEventListener('change', event => { +disableOsm.addEventListener("change", (event) => { browser.storage.sync.set({ disableOsm: !event.target.checked }); }); -alwaysProxy.addEventListener('change', event => { +alwaysProxy.addEventListener("change", (event) => { browser.storage.sync.set({ alwaysProxy: event.target.checked }); }); -onlyEmbeddedVideo.addEventListener('change', event => { +onlyEmbeddedVideo.addEventListener("change", (event) => { browser.storage.sync.set({ onlyEmbeddedVideo: event.target.checked }); }); -videoQuality.addEventListener('change', event => { +videoQuality.addEventListener("change", (event) => { browser.storage.sync.set({ - videoQuality: event.target.options[videoQuality.selectedIndex].value + videoQuality: event.target.options[videoQuality.selectedIndex].value, }); }); -removeTwitterSW.addEventListener('change', event => { +removeTwitterSW.addEventListener("change", (event) => { browser.storage.sync.set({ removeTwitterSW: !event.target.checked }); }); -invidiousDarkMode.addEventListener('change', event => { +invidiousDarkMode.addEventListener("change", (event) => { browser.storage.sync.set({ invidiousDarkMode: event.target.checked }); }); -persistInvidiousPrefs.addEventListener('change', event => { +persistInvidiousPrefs.addEventListener("change", (event) => { browser.storage.sync.set({ persistInvidiousPrefs: event.target.checked }); }); + +let invidiousVolumeChange = debounce(() => { + document.querySelector( + "#volume-value" + ).textContent = `${invidiousVolume.value}%`; + browser.storage.sync.set({ + invidiousVolume: invidiousVolume.value, + }); +}, 500); +invidiousVolume.addEventListener("input", invidiousVolumeChange); + +invidiousPlayerStyle.addEventListener("change", (event) => { + browser.storage.sync.set({ + invidiousPlayerStyle: + event.target.options[invidiousPlayerStyle.selectedIndex].value, + }); +}); + +let invidiousSubtitlesChange = debounce(() => { + if (invidiousInstance.checkValidity()) { + browser.storage.sync.set({ + invidiousSubtitles: invidiousSubtitles.value, + }); + } +}, 500); +invidiousSubtitles.addEventListener("input", invidiousSubtitlesChange); + +invidiousAutoplay.addEventListener("change", (event) => { + browser.storage.sync.set({ invidiousAutoplay: event.target.checked }); +}); + +theme.addEventListener("change", (event) => { + const value = event.target.options[theme.selectedIndex].value; + switch (value) { + case "dark-theme": + document.body.classList.add("dark-theme"); + document.body.classList.remove("light-theme"); + break; + case "light-theme": + document.body.classList.add("light-theme"); + document.body.classList.remove("dark-theme"); + break; + default: + document.body.classList.remove("light-theme"); + document.body.classList.remove("dark-theme"); + } + browser.storage.sync.set({ + theme: value, + }); +}); + +function autocomplete(input, list) { + let currentFocus; + input.addEventListener("focus", (e) => { + showOptions(e, true); + }); + input.addEventListener("input", (e) => { + const val = e.target.value; + if (!val) { + return false; + } + currentFocus = -1; + showOptions(e); + }); + input.addEventListener("keydown", function (e) { + let x = document.getElementById(this.id + "autocomplete-list"); + if (x) x = x.getElementsByTagName("div"); + if (e.keyCode == 40) { + currentFocus++; + addActive(x); + } else if (e.keyCode == 38) { + currentFocus--; + addActive(x); + } else if (e.keyCode == 13) { + e.preventDefault(); + if (currentFocus > -1) { + if (x) x[currentFocus].click(); + } + } + }); + function showOptions(event, showAll = false) { + let div, + i, + val = event.target.value; + closeAllLists(); + div = document.createElement("div"); + div.setAttribute("id", event.target.id + "autocomplete-list"); + div.setAttribute("class", "autocomplete-items"); + event.target.parentNode.appendChild(div); + for (i = 0; i < list.length; i++) { + if (list[i].toLowerCase().indexOf(val.toLowerCase()) > -1) { + div.appendChild(getItem(list[i], val)); + } else if (showAll) { + div.appendChild(getItem(list[i], val)); + } + } + } + function getItem(item, val) { + let div = document.createElement("div"); + div.innerHTML = "<strong>" + item.substr(0, val.length) + "</strong>"; + div.innerHTML += item.substr(val.length); + div.innerHTML += "<input type='hidden' value='" + item + "'>"; + div.addEventListener("click", function (e) { + input.value = e.target.getElementsByTagName("input")[0].value; + input.dispatchEvent(new Event("input")); + closeAllLists(); + }); + return div; + } + function addActive(x) { + if (!x) return false; + removeActive(x); + if (currentFocus >= x.length) currentFocus = 0; + if (currentFocus < 0) currentFocus = x.length - 1; + x[currentFocus].classList.add("autocomplete-active"); + } + function removeActive(x) { + for (let i = 0; i < x.length; i++) { + x[i].classList.remove("autocomplete-active"); + } + } + function closeAllLists(elmnt) { + let x = document.getElementsByClassName("autocomplete-items"); + for (let i = 0; i < x.length; i++) { + if (elmnt != x[i] && elmnt != input) { + x[i].parentNode.removeChild(x[i]); + } + } + } + document.addEventListener("click", (e) => { + if (!autocompletes.find((element) => element.id === e.target.id)) { + closeAllLists(e.target); + } + }); +} + +autocompletes.forEach((value) => { + autocomplete(document.getElementById(value.id), value.instances); +}); diff --git a/pages/popup/open.svg b/pages/popup/open.svg deleted file mode 100644 index 04f56c15..00000000 --- a/pages/popup/open.svg +++ /dev/null @@ -1,5 +0,0 @@ -<svg xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'> - <path d='M384,224V408a40,40,0,0,1-40,40H104a40,40,0,0,1-40-40V168a40,40,0,0,1,40-40H271.48' style='fill:none;stroke:#FFF;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px'/> - <polyline points='336 64 448 64 448 176' style='fill:none;stroke:#FFF;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px'/> - <line x1='224' y1='288' x2='440' y2='72' style='fill:none;stroke:#FFF;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px'/> -</svg> \ No newline at end of file diff --git a/pages/popup/popup.html b/pages/popup/popup.html index 2e0fd680..e06159a5 100644 --- a/pages/popup/popup.html +++ b/pages/popup/popup.html @@ -1,122 +1,170 @@ -<!doctype html> +<!DOCTYPE html> <html> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <title></title> + <link href="../styles.css" rel="stylesheet" /> + </head> -<head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <title></title> - <link href="../styles.css" rel="stylesheet"> -</head> + <body class="popup"> + <header class="popup"> + <div class="logo-container"> + <img + src="../../assets/images/icon128.png" + alt="Privacy Redirect logo" + /> + <h1> + <span data-localise="__MSG_privacy__" class="privacy">Privacy</span + ><br /><span data-localise="__MSG_redirect__">Redirect</span> + </h1> + </div> + <div class="version"> + <span data-localise="__MSG_version__">Version</span>: <span + id="version" + ></span> + </div> + </header> -<body class="popup"> - <header> - <div class="logo-container"> - <img src="../../images/icon128.png" alt="Privacy Redirect logo"> - <h1><span class="privacy">Privacy</span><br>Redirect</h1> - </div> - <div class="version"> - <span>Version: <span id="version"></span></span> - </div> - </header> + <section class="settings-block"> + <table class="option" aria-label="Toggle Nitter redirects"> + <tbody> + <tr> + <td> + <h1 data-localise="__MSG_disableNitter__">Nitter Redirects</h1> + </td> + <td> + <input + aria-hidden="true" + id="disable-nitter" + type="checkbox" + checked + /> + <label for="disable-nitter" class="checkbox-label"></label> + </td> + </tr> + </tbody> + </table> + </section> - <section class="options settings_block"> - <div class="onoffswitch switch" aria-label="Toggle Nitter redirects"> - <h1>Nitter Redirects</h1> - <input aria-hidden="true" id="disable-nitter" type="checkbox" checked> - <label for="disable-nitter" class="checkbox-label"> - </label> - </div> - </section> + <section class="settings-block"> + <table class="option" aria-label="Toggle Invidious redirects"> + <tbody> + <tr> + <td> + <h1 data-localise="__MSG_disableInvidious__"> + Invidious Redirects + </h1> + </td> + <td> + <input + aria-hidden="true" + id="disable-invidious" + type="checkbox" + checked + /> + <label for="disable-invidious" class="checkbox-label"> </label> + </td> + </tr> + </tbody> + </table> + </section> - <section class="options settings_block"> - <div class="onoffswitch switch" aria-label="Toggle Invidious redirects"> - <h1>Invidious Redirects</h1> - <input aria-hidden="true" id="disable-invidious" type="checkbox" checked> - <label for="disable-invidious" class="checkbox-label"> - </label> - </div> - </section> + <section class="settings-block"> + <table class="option" aria-label="Toggle Bibliogram redirects"> + <tbody> + <tr> + <td> + <h1 data-localise="__MSG_disableBibliogram__"> + Bibliogram Redirects + </h1> + </td> + <td> + <input + aria-hidden="true" + id="disable-bibliogram" + type="checkbox" + checked + /> + <label for="disable-bibliogram" class="checkbox-label"> </label> + </td> + </tr> + </tbody> + </table> + </section> - <section class="options settings_block"> - <div class="onoffswitch switch" aria-label="Toggle Bibliogram redirects"> - <h1>Bibliogram Redirects</h1> - <input aria-hidden="true" id="disable-bibliogram" type="checkbox" checked> - <label for="disable-bibliogram" class="checkbox-label"> - </label> - </div> - </section> + <section class="settings-block"> + <table class="option" aria-label="Toggle OpenStreetMap redirects"> + <tbody> + <tr> + <td> + <h1 data-localise="__MSG_disableOsm__"> + OpenStreetMap Redirects + </h1> + </td> + <td> + <input + aria-hidden="true" + id="disable-osm" + type="checkbox" + checked + /> + <label for="disable-osm" class="checkbox-label"> </label> + </td> + </tr> + </tbody> + </table> + </section> - <section class="options settings_block"> - <div class="onoffswitch switch" aria-label="Toggle OpenStreetMap redirects"> - <h1>OpenStreetMap Redirects</h1> - <input aria-hidden="true" id="disable-osm" type="checkbox" checked> - <label for="disable-osm" class="checkbox-label"> - </label> - </div> - </section> + <section class="settings-block"></section> - <section class="options settings_block"> - <h1>Nitter Instance</h1> - <input id="nitter-instance" list="nitter-instance-list" type="url" placeholder="https://nitter.net"> - <datalist id="nitter-instance-list"> - <option value="https://nitter.net"> - <option value="https://nitter.snopyta.org"> - <option value="https://nitter.42l.fr"> - <option value="https://nitter.nixnet.xyz"> - <option value="https://nitter.13ad.de"> - <option value="https://tw.openalgeria.org"> - <option value="https://nitter.pussthecat.org"> - <option value="https://nitter.mastodont.cat"> - <option value="https://nitter.dark.fail"> - <option value="https://nitter.tedomum.net"> - <option value="https://t.maisputain.ovh"> - <option value="http://3nzoldnxplag42gqjs23xvghtzf6t6yzssrtytnntc6ppc7xxuoneoad.onion"> - <option value="http://nitter.l4qlywnpwqsluw65ts7md3khrivpirse744un3x7mlskqauz5pyuzgqd.onion"> - <option value="http://3nzoldnxplag42gqjs23xvghtzf6t6yzssrtytnntc6ppc7xxuoneoad.onion"> - </datalist> - <h1>Invidious Instance</h1> - <input id="invidious-instance" list="invidious-instances-list" type="url" placeholder="https://invidio.us"> - <datalist id="invidious-instances-list"> - <option value="https://invidio.us"> - <option value="https://invidious.snopyta.org"> - <option value="https://invidiou.sh"> - <option value="https://yewtu.be"> - <option value="https://yt.maisputain.ovh"> - <option value="https://invidious.toot.koeln"> - <option value="https://invidious.ggc-project.de"> - <option value="https://invidious.toot.koeln"> - <option value="http://kgg2m7yk5aybusll.onion"> - <option value="http://axqzx4s6s54s32yentfqojs3x5i7faxza6xo3ehd4bzzsg2ii4fv2iid.onion"> - <option value="http://fz253lmuao3strwbfbmx46yu7acac2jz27iwtorgmbqlkurlclmancad.onion"> - <option value="http://qklhadlycap4cnod.onion"> - <option value="http://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion"> - <option value="http://mfqczy4mysscub2s.onion"> - </datalist> - <h1>Bibliogram Instance</h1> - <input id="bibliogram-instance" list="bibliogram-instance-list" type="url" placeholder="https://bibliogram.art"> - <datalist id="bibliogram-instance-list"> - <option value="https://bibliogram.art"> - <option value="https://bibliogram.snopyta.org"> - <option value="https://bibliogram.pussthecat.org"> - <option value="https://insta.maisputain.ovh"> - <option value="https://bibliogram.nixnet.services"> - </datalist> - <h1>OpenStreetMap Instance</h1> - <input id="osm-instance" list="osm-instance-list" type="url" placeholder="https://openstreetmap.org"> - <datalist id="osm-instance-list"> - <option value="https://openstreetmap.org"> - </datalist> - </section> + <footer> + <a class="button" id="more-options"> + <span data-localise="__MSG_moreOptions__">More Options </span> + <svg + xmlns="http://www.w3.org/2000/svg" + width="512" + height="512" + viewBox="0 0 512 512" + > + <path + d="M384,224V408a40,40,0,0,1-40,40H104a40,40,0,0,1-40-40V168a40,40,0,0,1,40-40H271.48" + style=" + fill: none; + stroke: inherit; + stroke-linecap: round; + stroke-linejoin: round; + stroke-width: 32px; + " + /> + <polyline + points="336 64 448 64 448 176" + style=" + fill: none; + stroke: inherit; + stroke-linecap: round; + stroke-linejoin: round; + stroke-width: 32px; + " + /> + <line + x1="224" + y1="288" + x2="440" + y2="72" + style=" + fill: none; + stroke: inherit; + stroke-linecap: round; + stroke-linejoin: round; + stroke-width: 32px; + " + /> + </svg> + </a> + </footer> - <footer> - <a class="button" id="more-options"> - <span>More Options </span> - <img height="18px" src="open.svg" alt="more-options" /> - </a> - </footer> - - <script src="./popup.js"></script> - -</body> - -</html> \ No newline at end of file + <script src="./popup.js"></script> + <script src="../../assets/javascript/localise.js"></script> + </body> +</html> diff --git a/pages/popup/popup.js b/pages/popup/popup.js index 66842c75..54eae408 100644 --- a/pages/popup/popup.js +++ b/pages/popup/popup.js @@ -1,33 +1,23 @@ -'use strict'; +"use strict"; -let nitterInstance = document.querySelector('#nitter-instance'); -let invidiousInstance = document.querySelector('#invidious-instance'); -let bibliogramInstance = document.querySelector('#bibliogram-instance'); -let osmInstance = document.querySelector('#osm-instance'); -let disableNitter = document.querySelector('#disable-nitter'); -let disableInvidious = document.querySelector('#disable-invidious'); -let disableBibliogram = document.querySelector('#disable-bibliogram'); -let disableOsm = document.querySelector('#disable-osm'); -let version = document.querySelector('#version'); +let disableNitter = document.querySelector("#disable-nitter"); +let disableInvidious = document.querySelector("#disable-invidious"); +let disableBibliogram = document.querySelector("#disable-bibliogram"); +let disableOsm = document.querySelector("#disable-osm"); +let version = document.querySelector("#version"); window.browser = window.browser || window.chrome; browser.storage.sync.get( [ - 'nitterInstance', - 'invidiousInstance', - 'bibliogramInstance', - 'osmInstance', - 'disableNitter', - 'disableInvidious', - 'disableBibliogram', - 'disableOsm' + "disableNitter", + "disableInvidious", + "disableBibliogram", + "disableOsm", + "theme", ], - result => { - nitterInstance.value = result.nitterInstance || ''; - invidiousInstance.value = result.invidiousInstance || ''; - bibliogramInstance.value = result.bibliogramInstance || ''; - osmInstance.value = result.osmInstance || ''; + (result) => { + if (result.theme) document.body.classList.add(result.theme); disableNitter.checked = !result.disableNitter; disableInvidious.checked = !result.disableInvidious; disableBibliogram.checked = !result.disableBibliogram; @@ -37,91 +27,22 @@ browser.storage.sync.get( version.textContent = browser.runtime.getManifest().version; -function debounce(func, wait, immediate) { - let timeout; - return () => { - let context = this, args = arguments; - let later = () => { - timeout = null; - if (!immediate) func.apply(context, args); - }; - let callNow = immediate && !timeout; - clearTimeout(timeout); - timeout = setTimeout(later, wait); - if (callNow) func.apply(context, args); - }; -}; - -function parseURL(urlString) { - if (urlString) { - try { - const url = new URL(urlString); - if (url.username && url.password) { - return `${url.protocol}//${url.username}:${url.password}@${url.host}` - } else { - return url.origin; - } - } catch (error) { - console.log(error); - return ''; - } - } else { - return ''; - } -} - -let nitterInstanceChange = debounce(() => { - if (nitterInstance.checkValidity()) { - browser.storage.sync.set({ - nitterInstance: parseURL(nitterInstance.value) - }); - } -}, 500); -nitterInstance.addEventListener('input', nitterInstanceChange); - -let invidiousInstanceChange = debounce(() => { - if (invidiousInstance.checkValidity()) { - browser.storage.sync.set({ - invidiousInstance: parseURL(invidiousInstance.value) - }); - } -}, 500); -invidiousInstance.addEventListener('input', invidiousInstanceChange); - -let bibliogramInstanceChange = debounce(() => { - if (bibliogramInstance.checkValidity()) { - browser.storage.sync.set({ - bibliogramInstance: parseURL(bibliogramInstance.value) - }); - } -}, 500); -bibliogramInstance.addEventListener('input', bibliogramInstanceChange); - -let osmInstanceChange = debounce(() => { - if (osmInstance.checkValidity()) { - browser.storage.sync.set({ - osmInstance: parseURL(osmInstance.value) - }); - } -}, 500); -osmInstance.addEventListener('input', osmInstanceChange); - -disableNitter.addEventListener('change', event => { +disableNitter.addEventListener("change", (event) => { browser.storage.sync.set({ disableNitter: !event.target.checked }); }); -disableInvidious.addEventListener('change', event => { +disableInvidious.addEventListener("change", (event) => { browser.storage.sync.set({ disableInvidious: !event.target.checked }); }); -disableBibliogram.addEventListener('change', event => { +disableBibliogram.addEventListener("change", (event) => { browser.storage.sync.set({ disableBibliogram: !event.target.checked }); }); -disableOsm.addEventListener('change', event => { +disableOsm.addEventListener("change", (event) => { browser.storage.sync.set({ disableOsm: !event.target.checked }); }); -document.querySelector('#more-options').addEventListener('click', () => { +document.querySelector("#more-options").addEventListener("click", () => { browser.runtime.openOptionsPage(); }); diff --git a/pages/styles.css b/pages/styles.css index 17b5f7f7..dd58676b 100644 --- a/pages/styles.css +++ b/pages/styles.css @@ -1,31 +1,41 @@ -:root { - --text-main: #FFF; - --text-secondary: #000; - --dark: #3C4043; - --darker: #292A2D; - --light: #E3E7EA; - --lighter: #FFF; - --active: #FF5B56; +body { + --text: #fff; + --bg-main: #3c4043; + --bg-secondary: #292a2d; + --active: #ff5b56; --space: 5px; --danger: #f04141; - --danger-light: #F9D0D5; + --danger-light: #f9d0d5; + --dark-grey: #767676; + --light-grey: #c3c3c3; +} + +body.light-theme { + --text: #000; + --bg-main: #e3e7ea; + --bg-secondary: #fff; +} + +.light-theme.popup, +.light-theme .popup { + background-color: var(--bg-secondary); } body { - color: var(--text-secondary); margin: 0; - width: 400px; + max-width: 400px; margin: auto; min-height: 572px; font-family: Sans-Serif; - background-color: var(--darker); + background-color: var(--bg-secondary); + color: var(--text); } .popup { width: 300px; min-height: auto; overflow: hidden; - background-color: var(--dark); + background-color: var(--bg-main); } input { @@ -35,8 +45,8 @@ input { } header { - background-color: var(--lighter); - color: var(--text-secondary); + background-color: var(--bg-main); + color: var(--text); display: flex; padding: var(--space); } @@ -45,7 +55,7 @@ header .logo-container { width: 100%; margin: var(--space) 0 var(--space) 0; display: flex; - align-items:center; + align-items: center; } header .logo-container img { @@ -75,7 +85,7 @@ header .version { h1 { font-size: 14px; - margin: var(--space) auto; + margin: 7px auto; } i { @@ -95,7 +105,7 @@ h3 { h1, h2 { - color: var(--text-main); + color: var(--text); } footer { @@ -106,26 +116,40 @@ footer a.button { margin: var(--space); } -/* Elements */ - -input[type=url], input[type=text], select { +input[type="url"], +input[type="text"], +select { width: 100%; box-sizing: border-box; margin-bottom: var(--space); + background-color: var(--bg-main); + border-style: inset; + color: var(--text); } -input[type=url] { +input[type="url"] { padding: 1px 2px; } -input[type=checkbox] { +input[type="checkbox"] { opacity: 0; } +input[type="radio"] { + appearance: radio; + -moz-appearance: radio; + -webkit-appearance: radio; +} + +input[type="radio"]:checked + label { + background: transparent; +} + .checkbox-label { + margin-left: 5px; background: grey; border-radius: 25px; - color: var(--text-main); + color: var(--text); cursor: pointer; display: block; float: right; @@ -137,37 +161,39 @@ input[type=checkbox] { } .checkbox-label:after { - background: #fff; + background: white; border-radius: 90px; - content: ''; + content: ""; height: 20px; left: var(--space); position: absolute; top: var(--space); - transition: 0.3s; /* Acts on transform below */ + transition: 0.3s; width: 20px; } -input:checked+label { + +input:checked + label { background: var(--active); } -/* position when active*/ -input:checked+label:after { + +input:checked + label:after { left: calc(100% - var(--space)); transform: translateX(-100%); } -.settings_block { +.settings-block { display: block; - padding: 10px 1em 1em 1em; + padding: 5px 10px 5px 10px; } -.settings_block h1 { +.settings-block h1 { float: left; } .button { border: var(--active) solid 1px; - color: var(--text-main); + color: var(--text); + stroke: var(--text); display: block; font-size: 12px; font-weight: bold; @@ -186,12 +212,13 @@ input:checked+label:after { .button:hover { background-color: var(--active); - color: #fff; + color: var(--text); + stroke: var(--text); } .button:active { background-color: var(--active); - box-shadow: 0 var(--space) var(--dark); + box-shadow: 0 var(--space) var(--bg-main); transform: translateY(4px); } @@ -207,13 +234,13 @@ input:invalid { .tab { overflow: hidden; - background-color: var(--darker); + background-color: var(--bg-secondary); } .tab button { border-top-left-radius: 10px; border-top-right-radius: 10px; - color: var(--text-main); + color: var(--text); background-color: inherit; float: left; border: none; @@ -221,7 +248,7 @@ input:invalid { cursor: pointer; padding: 14px 16px; transition: 0.3s; - border: solid 1px var(--dark); + border: solid 1px var(--bg-main); width: 33.333%; font-size: 14px; } @@ -231,106 +258,206 @@ input:invalid { } .tab button.active { - background-color: var(--dark); + background-color: var(--bg-main); } .tabcontent { padding-top: 10px; display: none; - border: solid 1px var(--dark); - background-color: var(--dark); + background-color: var(--bg-main); min-height: 510px; } -div.whitelist { +div.exceptions { clear: left; } -div.whitelist > input { +div.exceptions > input { width: 240px; float: left; } -#add-to-whitelist { - width: 120px; +#add-to-exceptions { float: right; border: var(--active) solid 1px; background-color: var(--active); - color: var(--text-main); + color: var(--text); font-weight: bold; cursor: pointer; - border-radius: 25px; + border-radius: 50%; + padding: 1px 1px 0px 1px; + margin-right: 5px; +} + +#add-to-exceptions svg { + height: 20px; + width: 20px; } ul { padding: 0; list-style-type: none; - color: var(--text-main); - margin-right: 20px; - margin-left: 20px; + color: var(--text); + margin: 20px 20px 0 20px; } li { - border-bottom: solid 0.5px var(--darker); + border-bottom: solid 0.5px var(--bg-secondary); padding: 20px 0px 20px 20px; } -#whitelist-items button { +#exceptions-items button { float: right; margin-right: -5px; border: var(--active) solid 1px; background-color: var(--active); - color: var(--text-main); + color: var(--text); font-weight: bold; cursor: pointer; border-radius: 50%; + padding: 2px 2px 0px 2px; } -@media (prefers-color-scheme: dark) { +.button svg { + height: 18px; + width: 18px; +} - body.popup, header, h1, input, select, div.tabcontent, button.tablinks.active { - background-color: var(--dark); - color: var(--text-main); - } +.autocomplete { + position: relative; + display: inline-block; + width: 100%; +} - body { - background-color: var(--darker); - } +.autocomplete input { + background: url(../assets/images/chevron-down.svg) right no-repeat; +} - a.button { - color: var(--text-main); - } +.autocomplete-items { + position: absolute; + border: 1px solid var(--bg-main); + border-bottom: none; + border-top: none; + z-index: 99; + top: 85%; + left: 0; + right: 0; + overflow-y: auto; + max-height: 175px; + color: var(--text); + overflow-x: hidden; + max-width: 380px; +} + +.autocomplete-items div { + padding: 10px; + cursor: pointer; + background-color: var(--bg-secondary); + border-bottom: 1px solid var(--bg-main); +} - ::placeholder { - color: var(--text-main); - opacity: 0.7; - } +.autocomplete-items div:hover { + background-color: var(--active); +} + +.autocomplete-active { + background-color: var(--active); + color: var(--text); +} +.option { + width: 100%; } -@media (prefers-color-scheme: light) { +.option td { + vertical-align: middle; +} - body.popup, header, h1, input, select, div.tabcontent, button.tablinks.active { - background-color: var(--lighter); - color: var(--text-secondary); - } +input[type="range"] { + -webkit-appearance: none; + margin: 18px 0; + width: 100%; +} - body { - background-color: var(--light); - } +input[type="range"]:focus { + outline: none; +} - a.button { - color: var(--text-secondary); +input[type="range"]::-webkit-slider-runnable-track { + width: 100%; + height: 8.4px; + cursor: pointer; + border-color: var(--dark-grey), var(--light-grey); + background: var(--bg-main); + border-radius: 1.3px; + border: 0.2px inset var(--dark-grey); +} + +input[type="range"]::-webkit-slider-thumb { + border-color: var(--active); + border: 1px solid var(--dark-grey); + height: 36px; + width: 16px; + border-radius: 3px; + background: var(--active); + cursor: pointer; + -webkit-appearance: none; + margin-top: -14px; +} + +input[type="range"]:focus::-webkit-slider-runnable-track { + background: var(--bg-main); +} + +input[type="range"]::-moz-range-track { + width: 100%; + height: 8.4px; + cursor: pointer; + border-color: var(--dark-grey), var(--light-grey); + background: var(--bg-main); + border-radius: 1.3px; + border: 0.2px inset var(--dark-grey); +} + +input[type="range"]::-moz-range-thumb { + border-color: var(--active); + border: 1px solid var(--dark-grey); + height: 36px; + width: 16px; + border-radius: 3px; + background: var(--active); + cursor: pointer; +} + +::placeholder { + color: var(--text); + opacity: 0.7; +} + +*:focus { + outline: var(--active) solid 2px; +} + +@media (prefers-color-scheme: light) { + body { + --text: #000; + --text-secondary: #fff; + --bg-main: #e3e7ea; + --bg-secondary: #fff; } - button.tablinks { - background-color: var(--light); - color: var(--text-secondary); + body.dark-theme { + --text: #fff; + --text-secondary: #000; + --bg-main: #3c4043; + --bg-secondary: #292a2d; } - ::placeholder { - color: var(--text-secondary); - opacity: 0.7; + .popup { + background-color: var(--bg-secondary); } +} +#volume-value { + float: right; } |