about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSimonBrazell <simon@brazell.com.au>2020-03-10 16:03:28 +1100
committerSimonBrazell <simon@brazell.com.au>2020-03-10 16:03:28 +1100
commit75e4b6a69cbb94c6394ec7e0b53039e3fd648f7d (patch)
tree2ae2c0184a8b01f263d953ba41f0595c233a37d7
parentUpdate store screenshots (diff)
downloadlibredirect-75e4b6a69cbb94c6394ec7e0b53039e3fd648f7d.zip
Add 'Always proxy video' as a settings & avoid youtube-dl.org redirects
-rw-r--r--background.js21
-rw-r--r--images/.DS_Storebin0 -> 6148 bytes
-rw-r--r--manifest.json2
-rw-r--r--pages/options/options.html9
-rw-r--r--pages/options/options.js8
5 files changed, 30 insertions, 10 deletions
diff --git a/background.js b/background.js
index 03733546..ed042da2 100644
--- a/background.js
+++ b/background.js
@@ -25,14 +25,15 @@ const layers = {
   'bicycling': 'C'
 }
 
-let nitterInstance;
-let invidiousInstance;
-let bibliogramInstance;
-let osmInstance;
 let disableNitter;
 let disableInvidious;
 let disableBibliogram;
 let disableOsm;
+let nitterInstance;
+let invidiousInstance;
+let bibliogramInstance;
+let osmInstance;
+let alwaysProxy;
 
 window.browser = window.browser || window.chrome;
 
@@ -56,6 +57,7 @@ browser.storage.sync.get(
     invidiousInstance = result.invidiousInstance || invidiousDefault;
     bibliogramInstance = result.bibliogramInstance || bibliogramDefault;
     osmInstance = result.osmInstance || osmDefault;
+    alwaysProxy = result.alwaysProxy;
   }
 );
 
@@ -84,6 +86,9 @@ browser.storage.onChanged.addListener(changes => {
   if ('disableOsm' in changes) {
     disableOsm = changes.disableOsm.newValue;
   }
+  if ('alwaysProxy' in changes) {
+    alwaysProxy = changes.alwaysProxy.newValue;
+  }
 });
 
 function addressToLatLng(address, callback) {
@@ -123,8 +128,10 @@ function redirectYouTube(url) {
     // Redirect requests for YouTube Player API to local files instead
     return browser.runtime.getURL('assets/www-widgetapi.js');
   } else {
-    // Proxy video through the server
-    url.searchParams.append('local', true);
+    // Proxy video through the server if enabled by user
+    if (alwaysProxy) {
+      url.searchParams.append('local', true);
+    }
     return `${invidiousInstance}${url.pathname}${url.search}`;
   }
 }
@@ -217,7 +224,7 @@ browser.webRequest.onBeforeRequest.addListener(
   details => {
     const url = new URL(details.url);
     let redirect;
-    if (url.host.match(youtubeRegex)) {
+    if (url.host.match(youtubeRegex) && !url.host.includes('youtube-dl.org')) {
       if (!disableInvidious) {
         redirect = {
           redirectUrl: redirectYouTube(url)
diff --git a/images/.DS_Store b/images/.DS_Store
new file mode 100644
index 00000000..5008ddfc
--- /dev/null
+++ b/images/.DS_Store
Binary files differdiff --git a/manifest.json b/manifest.json
index 02cc6f8e..188862b7 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,7 +1,7 @@
 {
   "name": "Privacy Redirect",
   "description": "Redirects Twitter, YouTube, Instagram & Google Maps requests to privacy friendly alternatives.",
-  "version": "1.1.14",
+  "version": "1.1.15",
   "manifest_version": 2,
   "background": {
     "scripts": [
diff --git a/pages/options/options.html b/pages/options/options.html
index 786ecde7..2c9c3e81 100644
--- a/pages/options/options.html
+++ b/pages/options/options.html
@@ -83,6 +83,15 @@
     </datalist>
   </section>
 
+  <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>&nbsp;
+      <label for="always-proxy" class="checkbox-label">
+      </label>
+    </div>
+  </section>
+
   <footer>
     <a class="button" id="save">Save</a>
   </footer>
diff --git a/pages/options/options.js b/pages/options/options.js
index aefca8fd..8b30d90d 100644
--- a/pages/options/options.js
+++ b/pages/options/options.js
@@ -8,6 +8,7 @@ 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 alwaysProxy = document.querySelector('#always-proxy');
 
 window.browser = window.browser || window.chrome;
 
@@ -20,7 +21,8 @@ browser.storage.sync.get(
     'disableNitter',
     'disableInvidious',
     'disableBibliogram',
-    'disableOsm'
+    'disableOsm',
+    'alwaysProxy'
   ],
   result => {
     nitterInstance.value = result.nitterInstance || '';
@@ -31,6 +33,7 @@ browser.storage.sync.get(
     disableInvidious.checked = !result.disableInvidious;
     disableBibliogram.checked = !result.disableBibliogram;
     disableOsm.checked = !result.disableOsm;
+    alwaysProxy.checked = result.alwaysProxy;
   }
 );
 
@@ -43,7 +46,8 @@ document.querySelector('#save').addEventListener('click', () => {
     disableNitter: !disableNitter.checked,
     disableInvidious: !disableInvidious.checked,
     disableBibliogram: !disableBibliogram.checked,
-    disableOsm: !disableOsm.checked
+    disableOsm: !disableOsm.checked,
+    alwaysProxy: alwaysProxy.checked
   });
   window.close();
 });
\ No newline at end of file