From 8bdaa8ae72d69a6fc22d7bec6ed5f55665343f41 Mon Sep 17 00:00:00 2001 From: SimonBrazell Date: Sun, 31 May 2020 10:26:15 +1000 Subject: Fixes #58 - No longer host YT JS assets --- background.js | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'background.js') 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) { -- cgit 1.4.1