From 748f3d0f3a85a5f0acb26ae7e792935da6d9ad93 Mon Sep 17 00:00:00 2001 From: SimonBrazell Date: Wed, 4 Nov 2020 21:55:42 +1100 Subject: Closes #113 - Added support for FreeTube --- background.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'background.js') 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); -- cgit 1.4.1