From 540b41ef0a752bf7aa0d90df37bdb69a28b6f39f Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Mon, 31 Jan 2022 21:01:16 +0300 Subject: Refining code. Adding frontend option to search --- src/pages/options/general.html | 105 +++++++++++ src/pages/options/general.js | 98 ++++++++++ src/pages/options/instagram.html | 53 ++++++ src/pages/options/instagram.js | 11 +- src/pages/options/maps.html | 43 +++++ src/pages/options/medium.html | 52 ++++++ src/pages/options/medium.js | 10 +- src/pages/options/options.html | 370 -------------------------------------- src/pages/options/options.js | 98 ---------- src/pages/options/reddit.html | 71 ++++++++ src/pages/options/reddit.js | 24 ++- src/pages/options/search.html | 71 ++++++++ src/pages/options/search.js | 69 +++++++ src/pages/options/searchEngine.js | 42 ----- src/pages/options/translate.html | 43 +++++ src/pages/options/twitter.html | 60 +++++++ src/pages/options/twitter.js | 12 +- src/pages/options/wikipedia.html | 51 ++++++ src/pages/options/wikipedia.js | 10 ++ src/pages/options/youtube.html | 116 ++++++++++++ src/pages/options/youtube.js | 37 ++-- 21 files changed, 910 insertions(+), 536 deletions(-) create mode 100644 src/pages/options/general.html create mode 100644 src/pages/options/general.js create mode 100644 src/pages/options/instagram.html create mode 100644 src/pages/options/maps.html create mode 100644 src/pages/options/medium.html delete mode 100644 src/pages/options/options.html delete mode 100644 src/pages/options/options.js create mode 100644 src/pages/options/reddit.html create mode 100644 src/pages/options/search.html create mode 100644 src/pages/options/search.js delete mode 100644 src/pages/options/searchEngine.js create mode 100644 src/pages/options/translate.html create mode 100644 src/pages/options/twitter.html create mode 100644 src/pages/options/wikipedia.html create mode 100644 src/pages/options/youtube.html (limited to 'src/pages/options') diff --git a/src/pages/options/general.html b/src/pages/options/general.html new file mode 100644 index 00000000..db0dedd2 --- /dev/null +++ b/src/pages/options/general.html @@ -0,0 +1,105 @@ + + + + + + + + LibRedirect Options + + + + + + + +
+
+

Theme

+ +
+ +
+
+

+ Enter a URL or Regular Expression to be excluded from redirects. +

+

+ All requests for or initiating from a URL that matches your exception + will be excluded from redirects. +

+

+ Note - Supports JavaScript regular expressions, excluding the + enclosing forward slashes. +

+
+
+ + + + + + + + + + + +
+

Add Exception

+
+ + + + + + + + +
+
+ +
+ + + + + + + \ No newline at end of file diff --git a/src/pages/options/general.js b/src/pages/options/general.js new file mode 100644 index 00000000..e77f2aee --- /dev/null +++ b/src/pages/options/general.js @@ -0,0 +1,98 @@ +"use strict"; + +import commonHelper from "../../assets/javascripts/helpers/common.js"; + +import shared from "./shared.js"; + +const domparser = new DOMParser(); + +let themeElement = document.getElementById("theme"); +let exceptions; + +window.browser = window.browser || window.chrome; + +function prependExceptionsItem(item, index) { + const li = document.createElement("li"); + li.appendChild(document.createTextNode(item.toString())); + const button = document.createElement("button"); + li.appendChild(button); + document.getElementById("exceptions-items").prepend(li); + const svg = ` + + + `; + button.appendChild(domparser.parseFromString(svg, "image/svg+xml").documentElement); + button.addEventListener("click", () => { + exceptions.splice(index, 1); + browser.storage.sync.set({ exceptions: exceptions }); + li.remove(); + }); +} + +browser.storage.sync.get( + [ + "exceptions", + "theme", + ], + (result) => { + themeElement.value = result.theme || ""; + if (result.theme) document.body.classList.add(result.theme); + exceptions = result.exceptions || []; + exceptions.forEach(prependExceptionsItem); + shared.autocompletes.forEach((value) => { + }); + } +); + +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); + if (type === "URL") { + value = value.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"); + } + exceptions.push(value); + browser.storage.sync.set({ + exceptions: exceptions, + }); + prependExceptionsItem(value, exceptions.indexOf(value)); + input.value = ""; + } catch (error) { + input.setCustomValidity("Invalid RegExp"); + } + } else { + input.setCustomValidity("Invalid RegExp"); + } +} +document.getElementById("add-to-exceptions").addEventListener("click", addToExceptions); + +themeElement.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 }); +}); + +document.querySelector("#update-instances").addEventListener("click", () => { + document.querySelector("#update-instances").innerHTML = '...'; + if (commonHelper.updateInstances()) + document.querySelector("#update-instances").innerHTML = 'Done!'; + else + document.querySelector("#update-instances").innerHTML = 'Failed Miserabely'; +}); diff --git a/src/pages/options/instagram.html b/src/pages/options/instagram.html new file mode 100644 index 00000000..37c14e54 --- /dev/null +++ b/src/pages/options/instagram.html @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + +
+
+

Enable

+ +
+
+

Instance

+
+ +
+
+ +
+

Instance List

+
+ +
    +
    +
    + + +
    + + + + + \ No newline at end of file diff --git a/src/pages/options/instagram.js b/src/pages/options/instagram.js index 7d2864e1..db31de1e 100644 --- a/src/pages/options/instagram.js +++ b/src/pages/options/instagram.js @@ -46,4 +46,13 @@ bibliogramRandomPoolElement.addEventListener("input", commonHelper.debounce(() = bibliogramRandomPool = commonHelper.filterList(bibliogramRandomPoolElement.value.split("\n")) commonHelper.updateListElement(bibliogramRandomPoolListElement, bibliogramRandomPool); browser.storage.sync.set({ bibliogramRandomPool: bibliogramRandomPool }); -}, 50)); \ No newline at end of file +}, 50)); + + +browser.storage.onChanged.addListener((changes) => { + if ("bibliogramRandomPool" in changes) { + bibliogramRandomPool = changes.bibliogramRandomPool.newValue; + bibliogramRandomPoolElement.value = bibliogramRandomPool.join("\n"); + commonHelper.updateListElement(bibliogramRandomPoolListElement, bibliogramRandomPool); + } +}) \ No newline at end of file diff --git a/src/pages/options/maps.html b/src/pages/options/maps.html new file mode 100644 index 00000000..5074c44f --- /dev/null +++ b/src/pages/options/maps.html @@ -0,0 +1,43 @@ + + + + + + + + + LibRedirect Options: Twitter + + + + + + +
    +
    +

    Maps (OpenStreetMap)

    + +
    +
    +

    Instance

    +
    + +
    +
    +
    + + + + + \ No newline at end of file diff --git a/src/pages/options/medium.html b/src/pages/options/medium.html new file mode 100644 index 00000000..a2343f2e --- /dev/null +++ b/src/pages/options/medium.html @@ -0,0 +1,52 @@ + + + + + + + + + LibRedirect Options: Twitter + + + + + +
    +
    +

    Medium (Scribe)

    + +
    +
    +

    Instance

    +
    + +
    +
    +
    +

    Instance List

    +
    + +
      +
      +
      +
      + + + + + + \ No newline at end of file diff --git a/src/pages/options/medium.js b/src/pages/options/medium.js index 6fbc390d..bd86089f 100644 --- a/src/pages/options/medium.js +++ b/src/pages/options/medium.js @@ -50,4 +50,12 @@ scribeRandomPoolElement.addEventListener("input", commonHelper.debounce(() => { scribeRandomPool = commonHelper.filterList(scribeRandomPoolElement.value.split("\n")) commonHelper.updateListElement(scribeRandomPoolListElement, scribeRandomPool); browser.storage.sync.set({ scribeRandomPool: scribeRandomPool }); -}, 50)); \ No newline at end of file +}, 50)); + +browser.storage.onChanged.addListener((changes) => { + if ("scribeRandomPool" in changes) { + scribeRandomPool = changes.scribeRandomPool.newValue; + scribeRandomPoolElement.value = scribeRandomPool.join("\n"); + commonHelper.updateListElement(scribeRandomPoolListElement, scribeRandomPool); + } +}) \ No newline at end of file diff --git a/src/pages/options/options.html b/src/pages/options/options.html deleted file mode 100644 index 04903e7f..00000000 --- a/src/pages/options/options.html +++ /dev/null @@ -1,370 +0,0 @@ - - - - - - - - - LibRedirect Options - - - - -
      - -
      -
      -

      Theme

      - -
      - -
      -
      -

      - Enter a URL or Regular Expression to be excluded from redirects. -

      -

      - All requests for or initiating from a URL that matches your exception - will be excluded from redirects. -

      -

      - Note - Supports JavaScript regular expressions, excluding the - enclosing forward slashes. -

      -
      -
      - - - - - - - - - - - -
      -

      Add Exception

      -
      - - - - - - - - -
      -
      -
        -
        - -
        -
        -

        Youtube (Invidious)

        - -
        - -
        -

        Instance

        -
        - -
        -
        - -
        -

        Random Instance Pool

        -
        - -
          -
          -
          - -
          -

          Use FreeTube over Invidious when possible

          - -
          - -
          -

          Always proxy videos through Invidious

          - -
          - -
          -

          Only redirect embedded video to Invidious

          - -
          - -
          -

          Video Quality

          - -
          - -
          -

          Dark mode

          - -
          - -
          -

          Volume: 50%

          - -
          - -
          -

          Player Style

          - -
          - -
          -

          Subtitles - language codes

          - -
          - -
          -

          Automatically play video on load

          - -
          - -
          -

          Persist preferences (as cookie)

          - -
          - - -
          - - - -
          -
          -

          Instagram (Bibliogram)

          - -
          -
          -

          Instance

          -
          - -
          -
          - -
          -

          Random instance pool

          -
          - -
            -
            -
            - - -
            - -
            - -
            -

            Reddit (LibReddit)

            - -
            - -
            -

            Instance

            -
            - -
            -
            - -
            -

            Frontend

            - -
            - -
            -

            LibReddit Random instance pool

            -
            - -
              -
              -
              - -
              -

              Teddit Random instance pool

              -
              - -
                -
                -
                - -
                - - - -
                -
                -

                Translate (SimplyTranslate)

                - -
                -
                -

                Instance

                -
                - -
                -
                - - -
                - -
                -
                -

                Maps (OpenStreetMap)

                - -
                -
                -

                Instance

                -
                - -
                -
                - - -
                - -
                -
                -

                Wikipedia (Wikiless)

                - -
                -
                -

                Instance

                -
                - -
                -
                - -
                -

                Random instance pool

                -
                - -
                  -
                  -
                  - -
                  - -
                  -
                  -

                  Medium (Scribe)

                  - -
                  -
                  -

                  Instance

                  -
                  - -
                  -
                  -
                  -

                  Random instance pool (comma-separated)

                  -
                  - -
                    -
                    -
                    -
                    - -
                    - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/pages/options/options.js b/src/pages/options/options.js deleted file mode 100644 index 5d6aed4e..00000000 --- a/src/pages/options/options.js +++ /dev/null @@ -1,98 +0,0 @@ -"use strict"; - -import commonHelper from "../../assets/javascripts/helpers/common.js"; - -import shared from "./shared.js"; - -const domparser = new DOMParser(); - -let themeElement = document.getElementById("theme"); -let exceptions; - -window.browser = window.browser || window.chrome; - -function prependExceptionsItem(item, index) { - const li = document.createElement("li"); - li.appendChild(document.createTextNode(item.toString())); - const button = document.createElement("button"); - li.appendChild(button); - document.getElementById("exceptions-items").prepend(li); - const svg = ` - - - `; - button.appendChild(domparser.parseFromString(svg, "image/svg+xml").documentElement); - button.addEventListener("click", () => { - exceptions.splice(index, 1); - browser.storage.sync.set({ exceptions: exceptions }); - li.remove(); - }); -} - -browser.storage.sync.get( - [ - "exceptions", - "theme", - ], - (result) => { - themeElement.value = result.theme || ""; - if (result.theme) document.body.classList.add(result.theme); - exceptions = result.exceptions || []; - exceptions.forEach(prependExceptionsItem); - shared.autocompletes.forEach((value) => { - }); - } -); - -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); - if (type === "URL") { - value = value.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"); - } - exceptions.push(value); - browser.storage.sync.set({ - exceptions: exceptions, - }); - prependExceptionsItem(value, exceptions.indexOf(value)); - input.value = ""; - } catch (error) { - input.setCustomValidity("Invalid RegExp"); - } - } else { - input.setCustomValidity("Invalid RegExp"); - } -} -document.getElementById("add-to-exceptions").addEventListener("click", addToExceptions); - -themeElement.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 }); -}); - -document.querySelector("#update-instances").addEventListener("click", () => { - document.querySelector("#update-instances").innerHTML = '...'; - if (commonHelper.getInstances()) - document.querySelector("#update-instances").innerHTML = 'Done!'; - else - document.querySelector("#update-instances").innerHTML = 'Failed Miserabely'; -}); diff --git a/src/pages/options/reddit.html b/src/pages/options/reddit.html new file mode 100644 index 00000000..b5af36f7 --- /dev/null +++ b/src/pages/options/reddit.html @@ -0,0 +1,71 @@ + + + + + + + + + LibRedirect Options: Twitter + + + + + + +
                    + +
                    +

                    Reddit

                    + +
                    + +
                    +

                    Instance

                    +
                    + +
                    +
                    + +
                    +

                    Frontend

                    + +
                    + +
                    +

                    LibReddit Instance List

                    +
                    + +
                      +
                      +
                      + +
                      +

                      Teddit Instance List

                      +
                      + +
                        +
                        +
                        + +
                        + + + + + + \ No newline at end of file diff --git a/src/pages/options/reddit.js b/src/pages/options/reddit.js index 59307096..6702c4de 100644 --- a/src/pages/options/reddit.js +++ b/src/pages/options/reddit.js @@ -39,10 +39,10 @@ browser.storage.sync.get( tedditRandomPoolElement.value = tedditRandomPool.join("\n"); commonHelper.updateListElement(tedditRandomPoolListElement, tedditRandomPool); - let id = "reddit-instance"; - let instances = redditInstances; - shared.autocompletes.push({ id: id, instances: instances }) - shared.autocomplete(document.getElementById(id), instances); + // let id = "reddit-instance"; + // let instances = redditInstances; + // shared.autocompletes.push({ id: id, instances: instances }) + // shared.autocomplete(document.getElementById(id), instances); } ) @@ -74,4 +74,18 @@ tedditRandomPoolElement.addEventListener("input", commonHelper.debounce(() => { tedditRandomPool = commonHelper.filterList(tedditRandomPoolElement.value.split("\n")) commonHelper.updateListElement(tedditRandomPoolListElement, tedditRandomPool); browser.storage.sync.set({ tedditRandomPool: tedditRandomPool }); -}, 50)); \ No newline at end of file +}, 50)); + +browser.storage.onChanged.addListener((changes) => { + if ("libredditRandomPool" in changes) { + libredditRandomPool = changes.libredditRandomPool.newValue; + libredditRandomPoolElement.value = libredditRandomPool.join("\n"); + commonHelper.updateListElement(libredditRandomPoolListElement, libredditRandomPool); + } + + if ("tedditRandomPool" in changes) { + tedditRandomPool = changes.tedditRandomPool.newValue; + tedditRandomPoolElement.value = tedditRandomPool.join("\n"); + commonHelper.updateListElement(tedditRandomPoolListElement, tedditRandomPool); + } +}) \ No newline at end of file diff --git a/src/pages/options/search.html b/src/pages/options/search.html new file mode 100644 index 00000000..6a5af775 --- /dev/null +++ b/src/pages/options/search.html @@ -0,0 +1,71 @@ + + + + + + + + + LibRedirect Options: Twitter + + + + + +
                        +
                        +

                        Search

                        + +
                        +
                        +

                        Instance

                        + + + +
                        + +
                        +

                        Frontend

                        + +
                        + +
                        +

                        SearX Instance List

                        +
                        + +
                          +
                          +
                          + +
                          +

                          Whoogle Instance List

                          +
                          + +
                            +
                            +
                            + +
                            + + + + + + + \ No newline at end of file diff --git a/src/pages/options/search.js b/src/pages/options/search.js new file mode 100644 index 00000000..dc3246db --- /dev/null +++ b/src/pages/options/search.js @@ -0,0 +1,69 @@ +import searchHelper from "../../assets/javascripts/helpers/google-search.js"; +import commonHelper from "../../assets/javascripts/helpers/common.js"; +import shared from "./shared.js"; + +const searchInstances = searchHelper.redirects; +let searchInstanceElement = document.getElementById("search-instance"); +let disableSearchElement = document.getElementById("disable-search"); +let searchFrontendElement = document.getElementById("search-frontend"); + +let searxRandomPoolElement = document.getElementById("searx-random-pool"); +let searxRandomPoolListElement = document.getElementById("searx-random-pool-list"); + +let whoogleRandomPoolElement = document.getElementById("whoogle-random-pool"); +let whoogleRandomPoolListElement = document.getElementById("whoogle-random-pool-list"); + +let searxRandomPool +let whoogleRandomPool + +browser.storage.sync.get( + [ + "searchInstance", + "disableSearch", + "searchFrontend", + "searxRandomPool", + "whoogleRandomPool" + ], + (result) => { + searchInstanceElement.value = (result.searchInstance && result.searchInstance.link) || ""; + disableSearchElement.checked = !result.disableSearch; + searchFrontendElement.value = result.searchFrontend; + + searxRandomPool = result.searxRandomPool || commonHelper.filterInstances(searchInstances.searx) + searxRandomPoolElement.value = searxRandomPool.join("\n"); + commonHelper.updateListElement(searxRandomPoolListElement, searxRandomPool); + + whoogleRandomPool = result.whoogleRandomPool || commonHelper.filterInstances(searchInstances.whoogle) + whoogleRandomPoolElement.value = whoogleRandomPool.join("\n"); + commonHelper.updateListElement(whoogleRandomPoolListElement, whoogleRandomPool); + + // let id = "search-instance" + // let instances = searchInstances.map((instance) => instance.link) + // shared.autocompletes.push({ id: id, instances: instances }) + // shared.autocomplete(document.getElementById(id), instances); + } +) + +const searchInstanceChange = commonHelper.debounce(() => { + const instance = searchInstances.find( + (instance) => instance.link === searchInstanceElement.value + ); + if (instance || !searchInstanceElement.value) { + browser.storage.sync.set({ + searchInstance: instance || searchInstanceElement.value, + }); + } else { + searchInstanceElement.setCustomValidity("Must be an instance from the list"); + } +}, 500); +searchInstanceElement.addEventListener("input", searchInstanceChange); + +searchFrontendElement.addEventListener("change", (event) => { + const value = event.target.options[searchFrontendElement.selectedIndex].value; + console.info("Search Frontend:", value) + browser.storage.sync.set({ searchFrontend: value }) +}); + +disableSearchElement.addEventListener("change", (event) => { + browser.storage.sync.set({ disableSearch: !event.target.checked }); +}); diff --git a/src/pages/options/searchEngine.js b/src/pages/options/searchEngine.js deleted file mode 100644 index 856e51c4..00000000 --- a/src/pages/options/searchEngine.js +++ /dev/null @@ -1,42 +0,0 @@ -import searchHelper from "../../assets/javascripts/helpers/google-search.js"; -import commonHelper from "../../assets/javascripts/helpers/common.js"; -import shared from "./shared.js"; - -const searchEngineInstances = searchHelper.redirects; -let searchEngineInstanceElement = document.getElementById("searchEngine-instance"); -let disableSearchEngineElement = document.getElementById("disable-searchEngine"); - -browser.storage.sync.get( - [ - "searchEngineInstance", - "disableSearchEngine", - ], - (result) => { - searchEngineInstanceElement.value = (result.searchEngineInstance && result.searchEngineInstance.link) || ""; - - disableSearchEngineElement.checked = !result.disableSearchEngine; - - let id = "searchEngine-instance" - let instances = searchEngineInstances.map((instance) => instance.link) - shared.autocompletes.push({ id: id, instances: instances }) - shared.autocomplete(document.getElementById(id), instances); - } -) - -const searchEngineInstanceChange = commonHelper.debounce(() => { - const instance = searchEngineInstances.find( - (instance) => instance.link === searchEngineInstanceElement.value - ); - if (instance || !searchEngineInstanceElement.value) { - browser.storage.sync.set({ - searchEngineInstance: instance || searchEngineInstanceElement.value, - }); - } else { - searchEngineInstanceElement.setCustomValidity("Must be an instance from the list"); - } -}, 500); -searchEngineInstanceElement.addEventListener("input", searchEngineInstanceChange); - -disableSearchEngineElement.addEventListener("change", (event) => { - browser.storage.sync.set({ disableSearchEngine: !event.target.checked }); -}); diff --git a/src/pages/options/translate.html b/src/pages/options/translate.html new file mode 100644 index 00000000..18ffc333 --- /dev/null +++ b/src/pages/options/translate.html @@ -0,0 +1,43 @@ + + + + + + + + + LibRedirect Options: Twitter + + + + +
                            +
                            +

                            Translate (SimplyTranslate)

                            + +
                            +
                            +

                            Instance

                            +
                            + +
                            +
                            +
                            + + + + + + + \ No newline at end of file diff --git a/src/pages/options/twitter.html b/src/pages/options/twitter.html new file mode 100644 index 00000000..87bc1c86 --- /dev/null +++ b/src/pages/options/twitter.html @@ -0,0 +1,60 @@ + + + + + + + + + LibRedirect Options: Twitter + + + + + + +
                            + +
                            +

                            Enable

                            + +
                            +
                            +

                            Instance

                            +
                            + +
                            +
                            + +
                            +

                            Instance List

                            +
                            + +
                              +
                              +
                              +
                              +

                              Proactively remove Twitter service worker

                              + +
                              + +
                              + + + + + + \ No newline at end of file diff --git a/src/pages/options/twitter.js b/src/pages/options/twitter.js index 3e9b2a4a..21ee66b7 100644 --- a/src/pages/options/twitter.js +++ b/src/pages/options/twitter.js @@ -23,11 +23,11 @@ browser.storage.sync.get( nitterInstanceElement.value = result.nitterInstance || ""; disableNitterElement.checked = !result.disableNitter; removeTwitterSWElement.checked = !result.removeTwitterSW; - + nitterRandomPool = result.nitterRandomPool || commonHelper.filterInstances(nitterInstances) nitterRandomPoolElement.value = nitterRandomPool.join("\n"); commonHelper.updateListElement(nitterRandomPoolListElement, nitterRandomPool); - + let id = "nitter-instance" let instances = nitterRandomPool shared.autocompletes.push({ id: id, instances: instances }) @@ -56,3 +56,11 @@ nitterRandomPoolElement.addEventListener("input", commonHelper.debounce(() => { commonHelper.updateListElement(nitterRandomPoolListElement, nitterRandomPool); browser.storage.sync.set({ nitterRandomPool: nitterRandomPool }); }, 50)); + +browser.storage.onChanged.addListener((changes) => { + if ("nitterRandomPool" in changes) { + nitterRandomPool = changes.nitterRandomPool.newValue; + nitterRandomPoolElement.value = nitterRandomPool.join("\n"); + commonHelper.updateListElement(nitterRandomPoolListElement, nitterRandomPool); + } +}) \ No newline at end of file diff --git a/src/pages/options/wikipedia.html b/src/pages/options/wikipedia.html new file mode 100644 index 00000000..309b876f --- /dev/null +++ b/src/pages/options/wikipedia.html @@ -0,0 +1,51 @@ + + + + + + + + + LibRedirect Options: Twitter + + + + + +
                              +
                              +

                              Wikipedia (Wikiless)

                              + +
                              +
                              +

                              Instance

                              +
                              + +
                              +
                              + +
                              +

                              Instance List

                              +
                              + +
                                +
                                +
                                +
                                + + + + + + \ No newline at end of file diff --git a/src/pages/options/wikipedia.js b/src/pages/options/wikipedia.js index 243c918e..8306d842 100644 --- a/src/pages/options/wikipedia.js +++ b/src/pages/options/wikipedia.js @@ -51,3 +51,13 @@ wikilessRandomPoolElement.addEventListener("input", commonHelper.debounce(() => browser.storage.sync.set({ wikilessRandomPool: wikilessRandomPool }); }, 50)); + +browser.storage.onChanged.addListener((changes) => { + if ("wikilessRandomPool" in changes) { + console.info("Wikiless updating"); + console.info(changes.wikilessRandomPool.newValue) + wikilessRandomPool = changes.wikilessRandomPool.newValue; + wikilessRandomPoolElement.value = wikilessRandomPool.join("\n"); + commonHelper.updateListElement(wikilessRandomPoolListElement, wikilessRandomPool); + } +}) \ No newline at end of file diff --git a/src/pages/options/youtube.html b/src/pages/options/youtube.html new file mode 100644 index 00000000..1eb4e125 --- /dev/null +++ b/src/pages/options/youtube.html @@ -0,0 +1,116 @@ + + + + + + + + + LibRedirect Options: Twitter + + + + + + +
                                +
                                +

                                Enable

                                + +
                                + +
                                +

                                Instance

                                + + + +
                                + +
                                +

                                Instance List

                                +
                                + +
                                  +
                                  +
                                  + +
                                  +

                                  Player Style

                                  + +
                                  + +
                                  +

                                  Dark mode

                                  + +
                                  + +
                                  +

                                  Volume: 50%

                                  + +
                                  + +
                                  +

                                  Use FreeTube over Invidious when possible

                                  + +
                                  + +
                                  +

                                  Always proxy videos through Invidious

                                  + +
                                  + +
                                  +

                                  Only redirect embedded video to Invidious

                                  + +
                                  + +
                                  +

                                  Video Quality

                                  + +
                                  + +
                                  +

                                  Subtitles - language codes

                                  + +
                                  + +
                                  +

                                  Automatically play video on load

                                  + +
                                  + +
                                  +

                                  Persist preferences (as cookie)

                                  + +
                                  + + +
                                  + + + + + + \ No newline at end of file diff --git a/src/pages/options/youtube.js b/src/pages/options/youtube.js index 60b31afa..8749a711 100644 --- a/src/pages/options/youtube.js +++ b/src/pages/options/youtube.js @@ -15,9 +15,9 @@ let invidiousAutoplayElement = document.getElementById("invidious-autoplay"); let invidiousRandomPoolElement = document.getElementById("invidious-random-pool"); let invidiousRandomPoolListElement = document.getElementById('invidious-random-pool-list'); let useFreeTubeElement = document.getElementById("use-freetube"); -let alwaysProxyElement = document.getElementById("always-proxy"); -let onlyEmbeddedVideoElement = document.getElementById("only-embed"); -let videoQualityElement = document.getElementById("video-quality"); +let invidiousAlwaysProxyElement = document.getElementById("always-proxy"); +let invidiousOnlyEmbeddedVideoElement = document.getElementById("only-embed"); +let invidiousVideoQualityElement = document.getElementById("video-quality"); let invidiousRandomPool; @@ -33,9 +33,9 @@ browser.storage.sync.get( "invidiousAutoplay", "invidiousRandomPool", "useFreeTube", - "alwaysProxy", - "onlyEmbeddedVideo", - "videoQuality", + "invidiousAlwaysProxy", + "invidiousOnlyEmbeddedVideo", + "invidiousVideoQuality", ], (result) => { invidiousInstanceElement.value = result.invidiousInstance || ""; @@ -47,9 +47,9 @@ browser.storage.sync.get( invidiousPlayerStyleElement.value = result.invidiousPlayerStyle || ""; invidiousSubtitlesElement.value = result.invidiousSubtitles || ""; useFreeTubeElement.checked = result.useFreeTube; - onlyEmbeddedVideoElement.checked = result.onlyEmbeddedVideo; - alwaysProxyElement.checked = result.alwaysProxy; - videoQualityElement.value = result.videoQuality || ""; + invidiousOnlyEmbeddedVideoElement.checked = result.invidiousOnlyEmbeddedVideo; + invidiousAlwaysProxyElement.checked = result.invidiousAlwaysProxy; + invidiousVideoQualityElement.value = result.invidiousVideoQuality || ""; invidiousAutoplayElement.checked = result.invidiousAutoplay; invidiousRandomPool = result.invidiousRandomPool || commonHelper.filterInstances(invidiousInstances) @@ -118,19 +118,22 @@ useFreeTubeElement.addEventListener("change", (event) => { browser.storage.sync.set({ useFreeTube: event.target.checked }); }); -alwaysProxyElement.addEventListener("change", (event) => { - browser.storage.sync.set({ alwaysProxy: event.target.checked }); +invidiousAlwaysProxyElement.addEventListener("change", (event) => { + browser.storage.sync.set({ invidiousAlwaysProxy: event.target.checked }); }); -onlyEmbeddedVideoElement.addEventListener("change", (event) => { - browser.storage.sync.set({ onlyEmbeddedVideo: event.target.checked }); +invidiousOnlyEmbeddedVideoElement.addEventListener("change", (event) => { + browser.storage.sync.set({ invidiousOnlyEmbeddedVideo: event.target.checked }); }); -videoQualityElement.addEventListener("change", (event) => { - browser.storage.sync.set({ videoQuality: event.target.options[videoQualityElement.selectedIndex].value }); +invidiousVideoQualityElement.addEventListener("change", (event) => { + browser.storage.sync.set({ invidiousVideoQuality: event.target.options[invidiousVideoQualityElement.selectedIndex].value }); }); browser.storage.onChanged.addListener((changes) => { - if ("invidiousRandomPool" in changes) - invidiousRandomPool.value = changes.invidiousRandomPool.newValue; + if ("invidiousRandomPool" in changes) { + invidiousRandomPool = changes.invidiousRandomPool.newValue; + invidiousRandomPoolElement.value = invidiousRandomPool.join("\n"); + commonHelper.updateListElement(invidiousRandomPoolListElement, invidiousRandomPool); + } }) \ No newline at end of file -- cgit 1.4.1