about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSimonBrazell <simon@brazell.com.au>2020-11-04 21:55:42 +1100
committerSimonBrazell <simon@brazell.com.au>2020-11-04 21:55:42 +1100
commit748f3d0f3a85a5f0acb26ae7e792935da6d9ad93 (patch)
tree018c2ebfb817613626d8b6b48ebdf7f73e1f6384
parentClean up invidious random instance list (diff)
downloadlibredirect-748f3d0f3a85a5f0acb26ae7e792935da6d9ad93.zip
Closes #113 - Added support for FreeTube
-rw-r--r--_locales/en/messages.json4
-rw-r--r--_locales/en/store.md11
-rw-r--r--background.js9
-rw-r--r--pages/options/options.html25
-rw-r--r--pages/options/options.js7
5 files changed, 53 insertions, 3 deletions
diff --git a/_locales/en/messages.json b/_locales/en/messages.json
index 2e106a7c..096deaa0 100644
--- a/_locales/en/messages.json
+++ b/_locales/en/messages.json
@@ -106,5 +106,9 @@
   "version": {
     "message": "Version",
     "description": "Version"
+  },
+  "useFreeTube": {
+    "message": "Use FreeTube over Invidious when possible",
+    "description": "Label for 'Use FreeTube over Invidious when possible' option (options)."
   }
 }
diff --git a/_locales/en/store.md b/_locales/en/store.md
index deef0093..70ed80e4 100644
--- a/_locales/en/store.md
+++ b/_locales/en/store.md
@@ -1,10 +1,13 @@
 # Extension Store (AMO & Chrome Web Store) Listing
 
 ## Summary:
+
 ```
 A simple web extension that redirects Twitter, YouTube, Instagram & Google Maps requests to privacy friendly alternatives.
 ```
+
 ## Description:
+
 ```
 Redirects Twitter, YouTube, Instagram, & Google Maps requests to privacy friendly alternatives - <a href='https://nitter.net/'>Nitter</a>, <a href='https://invidio.us/'>Invidious</a>, <a href='https://bibliogram.art/'>Bibliogram</a>, & <a href='https://www.openstreetmap.org'>OpenStreetMap</a>.
 
@@ -23,10 +26,12 @@ The code for this web extension is available on <a href='https://github.com/Simo
 <b>β˜… Donate: πŸ‘¨πŸ»β€πŸ’»</b>
 If you like this extension and are financially able please consider <a href='https://www.buymeacoffee.com/SimonBrazell'>buying me a coffee</a> β˜•οΈ ️to show your appreciation and support the continuation of the project.
 
-<b>β˜… What's New in This Version (v1.1.36) πŸ†•</b>
+<b>β˜… What's New in This Version (v1.1.42) πŸ†•</b>
 <ul>
-  <li>Added Russian language translation.</li>
-  <li>Fix Invidious autoplay parameter.</li>
+  <li>Added Polish language translation.</li>
+  <li>Added Chinese language translation.</li>
+  <li>Pruned the Invidious random instances list.</li>
+  <li>Added support for FreeTube redirects (where possible).</li>
 </ul>
 
 <b>β˜… Permissions: ℹ️</b>
diff --git a/background.js b/background.js
index ed94294b..45e01f89 100644
--- a/background.js
+++ b/background.js
@@ -119,6 +119,7 @@ let invidiousVolume;
 let invidiousPlayerStyle;
 let invidiousSubtitles;
 let invidiousAutoplay;
+let useFreeTube;
 let exceptions;
 
 window.browser = window.browser || window.chrome;
@@ -141,6 +142,7 @@ browser.storage.sync.get(
     "invidiousPlayerStyle",
     "invidiousSubtitles",
     "invidiousAutoplay",
+    "useFreeTube",
     "exceptions",
   ],
   (result) => {
@@ -165,6 +167,7 @@ browser.storage.sync.get(
     invidiousPlayerStyle = result.invidiousPlayerStyle;
     invidiousSubtitles = result.invidiousSubtitles || "";
     invidiousAutoplay = result.invidiousAutoplay;
+    useFreeTube = result.useFreeTube;
   }
 );
 
@@ -217,6 +220,9 @@ browser.storage.onChanged.addListener((changes) => {
   if ("invidiousAutoplay" in changes) {
     invidiousAutoplay = changes.invidiousAutoplay.newValue;
   }
+  if ("useFreeTube" in changes) {
+    useFreeTube = changes.useFreeTube.newValue;
+  }
   if ("exceptions" in changes) {
     exceptions = changes.exceptions.newValue.map((e) => {
       return new RegExp(e);
@@ -287,6 +293,9 @@ function redirectYouTube(url, initiator, type) {
   if (onlyEmbeddedVideo && type !== "sub_frame") {
     return null;
   }
+  if (useFreeTube) {
+    return `freetube://${url}`;
+  }
   // Apply settings
   if (alwaysProxy) {
     url.searchParams.append("local", true);
diff --git a/pages/options/options.html b/pages/options/options.html
index 6641e5c4..3bddd403 100644
--- a/pages/options/options.html
+++ b/pages/options/options.html
@@ -175,6 +175,31 @@
       <section class="settings-block">
         <table
           class="option"
+          aria-label="Redirect YouTube to FreeTube where possible"
+        >
+          <tbody>
+            <tr>
+              <td>
+                <h1 data-localise="__MSG_useFreeTube__">
+                  Use FreeTube over Invidious when possible
+                </h1>
+              </td>
+              <td>
+                <input
+                  aria-hidden="true"
+                  id="useFreeTube"
+                  type="checkbox"
+                  checked
+                />&nbsp;
+                <label for="useFreeTube" class="checkbox-label"> </label>
+              </td>
+            </tr>
+          </tbody>
+        </table>
+      </section>
+      <section class="settings-block">
+        <table
+          class="option"
           aria-label="Always proxy videos through Invidious"
         >
           <tbody>
diff --git a/pages/options/options.js b/pages/options/options.js
index 8149be7b..e6bb9837 100644
--- a/pages/options/options.js
+++ b/pages/options/options.js
@@ -71,6 +71,7 @@ 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 useFreeTube = document.getElementById("useFreeTube");
 let exceptions;
 
 window.browser = window.browser || window.chrome;
@@ -119,6 +120,7 @@ browser.storage.sync.get(
     "invidiousAutoplay",
     "exceptions",
     "theme",
+    "useFreeTube",
   ],
   (result) => {
     theme.value = result.theme || "";
@@ -146,6 +148,7 @@ browser.storage.sync.get(
     invidiousPlayerStyle.value = result.invidiousPlayerStyle || "";
     invidiousSubtitles.value = result.invidiousSubtitles || "";
     invidiousAutoplay.checked = result.invidiousAutoplay;
+    useFreeTube.checked = result.useFreeTube;
   }
 );
 
@@ -315,6 +318,10 @@ persistInvidiousPrefs.addEventListener("change", (event) => {
   browser.storage.sync.set({ persistInvidiousPrefs: event.target.checked });
 });
 
+useFreeTube.addEventListener("change", (event) => {
+  browser.storage.sync.set({ useFreeTube: event.target.checked });
+});
+
 let invidiousVolumeChange = debounce(() => {
   document.querySelector(
     "#volume-value"