diff --git a/src/background.ts b/src/background.ts index 41f2511..06ee3cc 100644 --- a/src/background.ts +++ b/src/background.ts @@ -47,7 +47,7 @@ const redirectYoutube = async (r) => { const title = await getTitle(query); const video = await searchByName(title); - const url = getPeertubeVideoURL(video, prefs, isEmbed); + const url = getPeertubeVideoURL(video, prefs, { isEmbed }); return { redirectUrl: url @@ -77,7 +77,7 @@ const redirectPeertube = async (r) => { return {}; // Don't redirect if original instance } - const url = getPeertubeVideoURL(video, prefs, isEmbed); + const url = getPeertubeVideoURL(video, prefs, { isEmbed }); return { redirectUrl: url diff --git a/src/peertube.ts b/src/peertube.ts index 250fa04..726bd2f 100644 --- a/src/peertube.ts +++ b/src/peertube.ts @@ -48,7 +48,7 @@ async function peertubeify() { case RedirectType.Show: { searchVideo() .then(async video => { - const link = videoLink(getPeertubeVideoURL(video, prefs, false), video); + const link = videoLink(getPeertubeVideoURL(video, prefs), video); removeVideoLink(); document.querySelector('body').appendChild(link); }).catch(removeVideoLink); diff --git a/src/util.ts b/src/util.ts index a669824..3027bc4 100644 --- a/src/util.ts +++ b/src/util.ts @@ -4,7 +4,7 @@ export function htmlToElement(html: string): Element { return template.content.firstElementChild; } -export function getPeertubeVideoURL(video, prefs, isEmbed) { +export function getPeertubeVideoURL(video, prefs, { isEmbed = false } = {}) { const endpoint = isEmbed ? 'embed' : 'watch'; return `https://${getPeertubeHost(video.account.host, prefs)}/videos/${endpoint}/${video.uuid}`; diff --git a/src/youtube.ts b/src/youtube.ts index 5267af3..b99148d 100644 --- a/src/youtube.ts +++ b/src/youtube.ts @@ -39,7 +39,7 @@ async function peertubeify(query: String) { case RedirectType.Show: { searchVideo(query) .then(async video => { - const url = getPeertubeVideoURL(video, prefs, false) + const url = getPeertubeVideoURL(video, prefs) const link = videoLink(url, video); removeVideoLink();