From f24189979c0fdc2b82928b0891ee6198e703bc91 Mon Sep 17 00:00:00 2001 From: Brian Lindner Date: Sat, 2 Nov 2019 20:49:09 -0400 Subject: [PATCH] Add Invidious support --- webextension/main.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/webextension/main.js b/webextension/main.js index 0d1ead4..1d52f43 100644 --- a/webextension/main.js +++ b/webextension/main.js @@ -132,6 +132,12 @@ function parseUrlPlay(url, pathname, playhost) { sendYouTube(match2[2], playhost); return; } + var invidiousRex = /^.*(invidio.us\/watch.*[\?\&]v=)([^#\&\?]*).*/; + var match2 = url.match(invidiousRex); + if (match2 && match2[2].length == 11) { + sendYouTube(match2[2], playhost); + return; + } var vimeoRex = /^.*vimeo.com\/([0-9]+)/; var match = url.match(vimeoRex); if (match) { @@ -253,7 +259,14 @@ function handleComplete(resp) { } function setupButton(){ - var gettingAllTabs = browser.tabs.query({url:['*://www.youtube.com/watch*','*://vimeo.com/*','*://twitch.tv/videos/*']}); + var gettingAllTabs = browser.tabs.query({ + url: [ + '*://www.invidio.us/watch*', + '*://www.youtube.com/watch*', + '*://vimeo.com/*', + '*://twitch.tv/videos/*' + ] + }); gettingAllTabs.then((tabs) => { for (let tab of tabs) { browser.pageAction.show(tab.id); @@ -265,10 +278,15 @@ function setupButton(){ function displayButton(tabId, changeInfo, tabInfo) { var regExp = /^.*(youtube.com\/watch.*[\?\&]v=)([^#\&\?]*).*/; + var invidiousRex = /^.*(invidio.us\/watch.*[\?\&]v=)([^#\&\?]*).*/; var vimeoRex = /^.*vimeo.com\/([0-9]+)/; var twitchVideoRex = /^.*twitch.tv\/videos\/([0-9]+)$/; - if (tabInfo.url.match(regExp) || tabInfo.url.match(vimeoRex) || tabInfo.url.match(twitchVideoRex)) { + if ( + tabInfo.url.match(regExp) || + tabInfo.url.match(invidiousRex) || + tabInfo.url.match(vimeoRex) || + tabInfo.url.match(twitchVideoRex)) { browser.pageAction.show(tabId); } }