about summary refs log tree commit diff stats
path: root/background.js
diff options
context:
space:
mode:
authorSimonBrazell <simon@brazell.com.au>2020-05-31 10:26:15 +1000
committerSimonBrazell <simon@brazell.com.au>2020-05-31 10:26:15 +1000
commit8bdaa8ae72d69a6fc22d7bec6ed5f55665343f41 (patch)
tree1bc239069675b7eb6584d3a57d443ccd27081fec /background.js
parentStop redirecting Google Maps JS API endpoints (#56) (diff)
downloadlibredirect-8bdaa8ae72d69a6fc22d7bec6ed5f55665343f41.zip
Fixes #58 - No longer host YT JS assets
Diffstat (limited to 'background.js')
-rw-r--r--background.js38
1 files changed, 17 insertions, 21 deletions
diff --git a/background.js b/background.js
index d7b7318c..c4783e3e 100644
--- a/background.js
+++ b/background.js
@@ -200,28 +200,24 @@ function redirectYouTube(url, initiator, type) {
   if (initiator && (initiator.origin === invidiousInstance || youtubeDomains.includes(initiator.host))) {
     return null;
   }
-  if (url.pathname.match(/iframe_api/)) {
-    // Redirect requests for YouTube Player API to local files instead
-    return browser.runtime.getURL('assets/iframe_api.js');
-  } else if (url.pathname.match(/www-widgetapi/)) {
-    // Redirect requests for YouTube Player API to local files instead
-    return browser.runtime.getURL('assets/www-widgetapi.js');
-  } else {
-    // Proxy video through the server if enabled by user
-    if (alwaysProxy) {
-      url.searchParams.append('local', true);
-    }
-    if (videoQuality) {
-      url.searchParams.append('quality', videoQuality);
-    }
-    if (onlyEmbeddedVideo && type !== 'sub_frame') {
-      return null;
-    }
-    if (invidiousDarkMode) {
-      url.searchParams.append('dark_mode', invidiousDarkMode);
-    }
-    return `${invidiousInstance}${url.pathname}${url.search}`;
+  if (url.pathname.match(/iframe_api/) || url.pathname.match(/www-widgetapi/)) {
+    // Don't redirect YouTube Player API.
+    return null;
+  }
+  // Proxy video through the server if enabled by user
+  if (alwaysProxy) {
+    url.searchParams.append('local', true);
+  }
+  if (videoQuality) {
+    url.searchParams.append('quality', videoQuality);
+  }
+  if (onlyEmbeddedVideo && type !== 'sub_frame') {
+    return null;
+  }
+  if (invidiousDarkMode) {
+    url.searchParams.append('dark_mode', invidiousDarkMode);
   }
+  return `${invidiousInstance}${url.pathname}${url.search}`;
 }
 
 function redirectTwitter(url, initiator) {