Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Invidious support #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions webextension/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}
Expand Down