Added feature request #35

This commit is contained in:
ManeraKai 2022-02-14 22:32:30 +03:00
parent 7b54087a63
commit 2a1c3ea554
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
4 changed files with 326 additions and 289 deletions

View File

@ -197,16 +197,63 @@ function setPersistInvidiousPrefs(val) {
console.log("persistInvidiousPrefs: ", persistInvidiousPrefs)
}
let alwaysusePreferred;
const getAlwaysusePreferred = () => alwaysusePreferred;
function setAlwaysusePreferred(val) {
alwaysusePreferred = val;
browser.storage.sync.set({ alwaysusePreferred })
console.log("alwaysusePreferred: ", alwaysusePreferred)
}
let invidiousHostNames = () => redirects.invidious.normal.map(link => new URL(link).host);
let pipedHostNames = () => redirects.piped.normal.map(link => new URL(link).host);
function isYoutube(url) {
if (frontend == 'invidious')
return (targets.some((rx) => rx.test(url.href)) | pipedHostNames().includes(url.host));
if (frontend == 'piped')
return (targets.some((rx) => rx.test(url.href)) | invidiousHostNames().includes(url.host));
function isYoutube(url, initiator) {
if (disableYoutube)
return null;
if (
initiator &&
(
redirects.invidious.normal.includes(initiator.origin) ||
redirects.piped.normal.includes(initiator.origin) ||
targets.includes(initiator.host)
)
)
return null;
if (url.pathname.match(/iframe_api/) || url.pathname.match(/www-widgetapi/)) return null; // Don't redirect YouTube Player API.
let pipedInstancesList = [...pipedRedirectsChecks, ...pipedCustomRedirects];
let invidiousInstancesList = [...invidiousRedirectsChecks, ...invidiousCustomRedirects];
let isTargets = targets.some((rx) => rx.test(url.href));
let protocolHost = `${url.protocol}//${url.host}`;
let isInvidious = redirects.invidious.normal.includes(protocolHost);
if (isInvidious)
for (const iterator of invidiousInstancesList)
if (iterator.indexOf(protocolHost) === 0) isInvidious = false;
let isPiped = redirects.piped.normal.includes(protocolHost);
if (isPiped)
for (const iterator of pipedInstancesList)
if (iterator.indexOf(protocolHost) === 0) isPiped = false;
if (frontend == 'invidious') {
if (alwaysusePreferred)
return isTargets | isPiped | isInvidious;
else
return isTargets | isPiped;
}
if (frontend == 'piped') {
if (alwaysusePreferred)
return isTargets | isPiped | isInvidious;
else
return isTargets | isInvidious;
}
else
return targets.some((rx) => rx.test(url.href))
return isTargets
}
async function init() {
@ -229,6 +276,7 @@ async function init() {
"invidiousCustomRedirects",
"pipedRedirectsChecks",
"pipedCustomRedirects",
"alwaysusePreferred",
],
(result) => {
if (result.youtubeRedirects) redirects = result.youtubeRedirects;
@ -253,6 +301,8 @@ async function init() {
persistInvidiousPrefs = result.persistInvidiousPrefs ?? false;
alwaysusePreferred = result.alwaysusePreferred ?? true;
resolve();
});
@ -267,27 +317,17 @@ function invidiousInitCookies(tabId) {
});
}
function redirect(url, initiator, type) {
if (disableYoutube)
return null;
if (
initiator &&
(
redirects.invidious.normal.includes(initiator.origin) ||
redirects.piped.normal.includes(initiator.origin) ||
targets.includes(initiator.host)
)
)
return null;
if (url.pathname.match(/iframe_api/) || url.pathname.match(/www-widgetapi/)) return null; // Don't redirect YouTube Player API.
function redirect(url, type) {
if (frontend == 'freeTube' && type === "main_frame")
return `freetube://${url}`;
else if (frontend == 'invidious') {
let instancesList = [...invidiousRedirectsChecks, ...invidiousCustomRedirects];
if (instancesList.length === 0) return null;
let randomInstance = commonHelper.getRandomInstance(instancesList);
if (invidiousOnlyEmbeddedVideo && type !== "sub_frame") return null;
if (invidiousAlwaysProxy != "DEFAULT") url.searchParams.append("local", invidiousAlwaysProxy);
@ -298,35 +338,21 @@ function redirect(url, initiator, type) {
if (invidiousSubtitles.trim() != '') url.searchParams.append("subtitles", invidiousSubtitles);
if (invidiousAutoplay != "DEFAULT") url.searchParams.append("autoplay", invidiousAutoplay);
let instancesList = [...invidiousRedirectsChecks, ...invidiousCustomRedirects];
if (instancesList.length === 0)
return null;
let randomInstance = commonHelper.getRandomInstance(instancesList)
return `${randomInstance}${url.pathname.replace("/shorts/", "/watch?v=")}${url.search}`;
} else if (frontend == 'piped') {
if (invidiousOnlyEmbeddedVideo && type !== "sub_frame") return null;
let instancesList = [...pipedRedirectsChecks, ...pipedCustomRedirects];
if (instancesList.length === 0) return null;
let randomInstance = commonHelper.getRandomInstance(instancesList);
let randomInstance = commonHelper.getRandomInstance(instancesList)
if (invidiousOnlyEmbeddedVideo && type !== "sub_frame") return null;
if (invidiousTheme != "DEFAULT") url.searchParams.append("theme", invidiousTheme);
if (invidiousVolume != "--") url.searchParams.append("volume", invidiousVolume / 100);
if (invidiousAutoplay != "DEFAULT") url.searchParams.append("playerAutoPlay", invidiousAutoplay);
if (url.hostname.endsWith("youtube.com") || url.hostname.endsWith("youtube-nocookie.com") || invidiousHostNames().includes(url.hostname))
return `${randomInstance}${url.pathname.replace("/shorts/", "/watch?v=")}${url.search}`;
if (url.hostname.endsWith("youtu.be") && url.pathname.length > 1)
return `${randomInstance}/watch?v=${url.pathname.substring(1)}`;
return `${randomInstance}${url.pathname.replace("/shorts/", "/watch?v=")}${url.search}`;
}
return 'CANCEL';
}
@ -387,5 +413,8 @@ export default {
getPipedCustomRedirects,
setPipedCustomRedirects,
getAlwaysusePreferred,
setAlwaysusePreferred,
init,
};

View File

@ -47,7 +47,7 @@ browser.webRequest.onBeforeRequest.addListener(
if (exceptionsHelper.isException(url)) newUrl = null;
else if (youtubeHelper.isYoutube(url)) newUrl = youtubeHelper.redirect(url, initiator, details.type)
else if (youtubeHelper.isYoutube(url, initiator)) newUrl = youtubeHelper.redirect(url, initiator, details.type)
else if (twitterHelper.isTwitter(url)) newUrl = twitterHelper.redirect(url, initiator);

View File

@ -2,269 +2,271 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="../../../assets/images/libredirect.svg" />
<link href="../../stylesheets/styles.css" rel="stylesheet" />
<title>LibRedirect options: Twitter</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="../../../assets/images/libredirect.svg" />
<link href="../../stylesheets/styles.css" rel="stylesheet" />
<title>LibRedirect options: Twitter</title>
</head>
<body class="option">
<section class="links">
<div class="title">
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M12 5.69l5 4.5V18h-2v-6H9v6H7v-7.81l5-4.5M12 3L2 12h3v8h6v-6h2v6h6v-8h3L12 3z" />
</svg>
<a href="../general/general.html">General</a>
</div>
<div class="title">
<img src="../../../assets/images/youtube-icon.png" />
<a href="../youtube/youtube.html" class="selected">Youtube</a>
</div>
<div class="title">
<img src="../../../assets/images/twitter-icon.png" />
<a href="../twitter/twitter.html">Twitter</a>
</div>
<div class="title">
<img src="../../../assets/images/instagram-icon.png" />
<a href="../instagram/instagram.html">Instagram</a>
</div>
<div class="title">
<img src="../../../assets/images/tiktok-icon.png" />
<a href="../tiktok/tiktok.html">TikTok</a>
</div>
<div class="title">
<img src="../../../assets/images/reddit-icon.png" />
<a href="../reddit/reddit.html">Reddit</a>
</div>
<div class="title">
<img src="../../../assets/images/imgur-icon.png" />
<a href="../imgur/imgur.html">Imgur</a>
</div>
<div class="title">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<section class="links">
<div class="title">
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M12 5.69l5 4.5V18h-2v-6H9v6H7v-7.81l5-4.5M12 3L2 12h3v8h6v-6h2v6h6v-8h3L12 3z" />
</svg>
<a href="../general/general.html">General</a>
</div>
<div class="title">
<img src="../../../assets/images/youtube-icon.png" />
<a href="../youtube/youtube.html" class="selected">Youtube</a>
</div>
<div class="title">
<img src="../../../assets/images/twitter-icon.png" />
<a href="../twitter/twitter.html">Twitter</a>
</div>
<div class="title">
<img src="../../../assets/images/instagram-icon.png" />
<a href="../instagram/instagram.html">Instagram</a>
</div>
<div class="title">
<img src="../../../assets/images/tiktok-icon.png" />
<a href="../tiktok/tiktok.html">TikTok</a>
</div>
<div class="title">
<img src="../../../assets/images/reddit-icon.png" />
<a href="../reddit/reddit.html">Reddit</a>
</div>
<div class="title">
<img src="../../../assets/images/imgur-icon.png" />
<a href="../imgur/imgur.html">Imgur</a>
</div>
<div class="title">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path
d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" />
</svg>
<a href="../search/search.html">Search</a>
</div>
<div class="title">
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path
d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z" />
</svg>
<a href="../translate/translate.html">Translate</a>
</div>
<div class="title">
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path
d="M20.5 3l-.16.03L15 5.1 9 3 3.36 4.9c-.21.07-.36.25-.36.48V20.5c0 .28.22.5.5.5l.16-.03L9 18.9l6 2.1 5.64-1.9c.21-.07.36-.25.36-.48V3.5c0-.28-.22-.5-.5-.5zM10 5.47l4 1.4v11.66l-4-1.4V5.47zm-5 .99l3-1.01v11.7l-3 1.16V6.46zm14 11.08l-3 1.01V6.86l3-1.16v11.84z" />
</svg>
<a href="../maps/maps.html">Maps</a>
</div>
<div class="title">
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24"
width="24px" fill="currentColor">
<g>
<rect fill="none" height="24" width="24" />
</g>
<g>
<g />
<g>
<path
d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" />
</svg>
<a href="../search/search.html">Search</a>
</div>
<div class="title">
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
d="M21,5c-1.11-0.35-2.33-0.5-3.5-0.5c-1.95,0-4.05,0.4-5.5,1.5c-1.45-1.1-3.55-1.5-5.5-1.5S2.45,4.9,1,6v14.65 c0,0.25,0.25,0.5,0.5,0.5c0.1,0,0.15-0.05,0.25-0.05C3.1,20.45,5.05,20,6.5,20c1.95,0,4.05,0.4,5.5,1.5c1.35-0.85,3.8-1.5,5.5-1.5 c1.65,0,3.35,0.3,4.75,1.05c0.1,0.05,0.15,0.05,0.25,0.05c0.25,0,0.5-0.25,0.5-0.5V6C22.4,5.55,21.75,5.25,21,5z M21,18.5 c-1.1-0.35-2.3-0.5-3.5-0.5c-1.7,0-4.15,0.65-5.5,1.5V8c1.35-0.85,3.8-1.5,5.5-1.5c1.2,0,2.4,0.15,3.5,0.5V18.5z" />
<g>
<path
d="M17.5,10.5c0.88,0,1.73,0.09,2.5,0.26V9.24C19.21,9.09,18.36,9,17.5,9c-1.7,0-3.24,0.29-4.5,0.83v1.66 C14.13,10.85,15.7,10.5,17.5,10.5z" />
<path
d="M13,12.49v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26V11.9c-0.79-0.15-1.64-0.24-2.5-0.24 C15.8,11.66,14.26,11.96,13,12.49z" />
<path
d="M17.5,14.33c-1.7,0-3.24,0.29-4.5,0.83v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26v-1.52 C19.21,14.41,18.36,14.33,17.5,14.33z" />
</g>
</g>
</g>
</svg>
<a href="../wikipedia/wikipedia.html">Wikipedia</a>
</div>
<div class="title">
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24"
width="24px" fill="currentColor">
<g>
<rect fill="none" height="24" width="24" />
<g>
<path
d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z" />
</svg>
<a href="../translate/translate.html">Translate</a>
</div>
<div class="title">
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path
d="M20.5 3l-.16.03L15 5.1 9 3 3.36 4.9c-.21.07-.36.25-.36.48V20.5c0 .28.22.5.5.5l.16-.03L9 18.9l6 2.1 5.64-1.9c.21-.07.36-.25.36-.48V3.5c0-.28-.22-.5-.5-.5zM10 5.47l4 1.4v11.66l-4-1.4V5.47zm-5 .99l3-1.01v11.7l-3 1.16V6.46zm14 11.08l-3 1.01V6.86l3-1.16v11.84z" />
</svg>
<a href="../maps/maps.html">Maps</a>
</div>
<div class="title">
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24"
width="24px" fill="currentColor">
<g>
<rect fill="none" height="24" width="24" />
</g>
<g>
<g />
<g>
<path
d="M21,5c-1.11-0.35-2.33-0.5-3.5-0.5c-1.95,0-4.05,0.4-5.5,1.5c-1.45-1.1-3.55-1.5-5.5-1.5S2.45,4.9,1,6v14.65 c0,0.25,0.25,0.5,0.5,0.5c0.1,0,0.15-0.05,0.25-0.05C3.1,20.45,5.05,20,6.5,20c1.95,0,4.05,0.4,5.5,1.5c1.35-0.85,3.8-1.5,5.5-1.5 c1.65,0,3.35,0.3,4.75,1.05c0.1,0.05,0.15,0.05,0.25,0.05c0.25,0,0.5-0.25,0.5-0.5V6C22.4,5.55,21.75,5.25,21,5z M21,18.5 c-1.1-0.35-2.3-0.5-3.5-0.5c-1.7,0-4.15,0.65-5.5,1.5V8c1.35-0.85,3.8-1.5,5.5-1.5c1.2,0,2.4,0.15,3.5,0.5V18.5z" />
<g>
<path
d="M17.5,10.5c0.88,0,1.73,0.09,2.5,0.26V9.24C19.21,9.09,18.36,9,17.5,9c-1.7,0-3.24,0.29-4.5,0.83v1.66 C14.13,10.85,15.7,10.5,17.5,10.5z" />
<path
d="M13,12.49v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26V11.9c-0.79-0.15-1.64-0.24-2.5-0.24 C15.8,11.66,14.26,11.96,13,12.49z" />
<path
d="M17.5,14.33c-1.7,0-3.24,0.29-4.5,0.83v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26v-1.52 C19.21,14.41,18.36,14.33,17.5,14.33z" />
</g>
</g>
</g>
</svg>
<a href="../wikipedia/wikipedia.html">Wikipedia</a>
</div>
<div class="title">
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24"
width="24px" fill="currentColor">
<g>
<rect fill="none" height="24" width="24" />
<g>
<path
d="M19,5v14H5V5H19 M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3L19,3z" />
</g>
<path d="M14,17H7v-2h7V17z M17,13H7v-2h10V13z M17,9H7V7h10V9z" />
</g>
</svg>
<a href="../medium/medium.html">Medium</a>
</div>
</section>
d="M19,5v14H5V5H19 M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3L19,3z" />
</g>
<path d="M14,17H7v-2h7V17z M17,13H7v-2h10V13z M17,9H7V7h10V9z" />
</g>
</svg>
<a href="../medium/medium.html">Medium</a>
</div>
</section>
<section class="option-block">
<section class="option-block">
<div class="some-block option-block">
<h4>Enable</h4>
<input id="disable-invidious" type="checkbox" checked />
</div>
<div class="some-block option-block">
<h4>Frontend</h4>
<select id="youtube-frontend">
<option value="piped">Piped</option>
<option value="invidious">Invidious</option>
<option value="freeTube">FreeTube</option>
</select>
</div>
<hr>
<div id="invidious-piped">
<div class="some-block option-block">
<h4>Only Redirect Embedded-Video</h4>
<input id="only-embed" type="checkbox" checked />
</div>
<div class="some-block option-block">
<h4>Always use Preffered Instances</h4>
<input id="always-use-preferred" type="checkbox" checked />
</div>
<div class="some-block option-block">
<h4>Volume: <span id="volume-value">50%</span></h4>
<input id="invidious-volume" name="invidious-volume" type="range" min="0" max="100" step="1" />
<button type="button" class="default" id="clear-invidious-volume">
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path
d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" />
</svg>
</button>
</div>
<div class="some-block option-block">
<h4>Theme</h4>
<select id="invidious-theme">
<option value="DEFAULT">Default</option>
<option value="dark">Dark</option>
<option value="light">Light</option>
</select>
</div>
<div class="some-block option-block">
<h4>Autoplay Video</h4>
<select id="invidious-autoplay">
<option value="DEFAULT">Default</option>
<option value="true">True</option>
<option value="false">False</option>
</select>
</div>
</div>
<div id="invidious">
<div class="some-block option-block">
<h4>Player Style</h4>
<select id="invidious-player-style">
<option value="DEFAULT">Default</option>
<option value="invidious">Invidious</option>
<option value="youtube">YouTube</option>
</select>
</div>
<div class="some-block option-block">
<h4>Always proxy videos</h4>
<select id="invidious-always-proxy">
<option value="DEFAULT">Default</option>
<option value="true">True</option>
<option value="true">False</option>
</select>
</div>
<div class="some-block option-block">
<h4>Video Quality</h4>
<select id="video-quality">
<option value="DEFAULT">Default</option>
<option value="hd720">720p</option>
<option value="medium">480p</option>
<option value="dash">DASH (adaptive quality)</option>
</option>
</select>
</div>
<div class="some-block option-block">
<h4>Subtitles</h4>
<input id="invidious-subtitles" placeholder="en, ar, es" type="text" />
</div>
<div class="some-block option-block">
<h4>Persist preferences (as cookie)</h4>
<input id="persist-invidious-prefs" type="checkbox" checked />
</div>
<hr>
<div class="some-block option-block">
<h4>Default Instances</h4>
</div>
<div class="checklist" id="invidious-checklist">
</div>
<hr>
<div class="some-block option-block">
<h4>Custom Instances</h4>
</div>
<form id="custom-invidious-instance-form">
<div class="some-block option-block">
<h4>Enable</h4>
<input id="disable-invidious" type="checkbox" checked />
<input id="invidious-custom-instance" placeholder="https://invidious.com" type="url" />
<button type="submit" class="add" id="invidious-add-instance">
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</svg>
</button>
</div>
</form>
<div class="checklist" id="invidious-custom-checklist"></div>
</div>
<div id="piped">
<hr>
<div class="some-block option-block">
<h4>Default Instances</h4>
</div>
<div class="checklist" id="piped-checklist">
</div>
<hr>
<div class="some-block option-block">
<h4>Custom Instances</h4>
</div>
<form id="custom-piped-instance-form">
<div class="some-block option-block">
<h4>Frontend</h4>
<select id="youtube-frontend">
<option value="piped">Piped</option>
<option value="invidious">Invidious</option>
<option value="freeTube">FreeTube</option>
</select>
<input id="piped-custom-instance" placeholder="https://piped.com" type="url" />
<button type="submit" class="add" id="piped-add-instance">
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</svg>
</button>
</div>
</form>
<div class="checklist" id="piped-custom-checklist"></div>
</div>
<hr>
</section>
<div id="invidious-piped">
<div class="some-block option-block">
<h4>Only Redirect Embedded-Video</h4>
<input id="only-embed" type="checkbox" checked />
</div>
<div class="some-block option-block">
<h4>Volume: <span id="volume-value">50%</span></h4>
<input id="invidious-volume" name="invidious-volume" type="range" min="0" max="100" step="1" />
<button type="button" class="default" id="clear-invidious-volume">
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"
fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path
d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" />
</svg>
</button>
</div>
<div class="some-block option-block">
<h4>Theme</h4>
<select id="invidious-theme">
<option value="DEFAULT">Default</option>
<option value="dark">Dark</option>
<option value="light">Light</option>
</select>
</div>
<div class="some-block option-block">
<h4>Autoplay Video</h4>
<select id="invidious-autoplay">
<option value="DEFAULT">Default</option>
<option value="true">True</option>
<option value="false">False</option>
</select>
</div>
</div>
<div id="invidious">
<div class="some-block option-block">
<h4>Player Style</h4>
<select id="invidious-player-style">
<option value="DEFAULT">Default</option>
<option value="invidious">Invidious</option>
<option value="youtube">YouTube</option>
</select>
</div>
<div class="some-block option-block">
<h4>Always proxy videos</h4>
<select id="invidious-always-proxy">
<option value="DEFAULT">Default</option>
<option value="true">True</option>
<option value="true">False</option>
</select>
</div>
<div class="some-block option-block">
<h4>Video Quality</h4>
<select id="video-quality">
<option value="DEFAULT">Default</option>
<option value="hd720">720p</option>
<option value="medium">480p</option>
<option value="dash">DASH (adaptive quality)</option>
</option>
</select>
</div>
<div class="some-block option-block">
<h4>Subtitles</h4>
<input id="invidious-subtitles" placeholder="en, ar, es" type="text" />
</div>
<div class="some-block option-block">
<h4>Persist preferences (as cookie)</h4>
<input id="persist-invidious-prefs" type="checkbox" checked />
</div>
<hr>
<div class="some-block option-block">
<h4>Default Instances</h4>
</div>
<div class="checklist" id="invidious-checklist">
</div>
<hr>
<div class="some-block option-block">
<h4>Custom Instances</h4>
</div>
<form id="custom-invidious-instance-form">
<div class="some-block option-block">
<input id="invidious-custom-instance" placeholder="https://invidious.com" type="url" />
<button type="submit" class="add" id="invidious-add-instance">
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</svg>
</button>
</div>
</form>
<div class="checklist" id="invidious-custom-checklist"></div>
</div>
<div id="piped">
<hr>
<div class="some-block option-block">
<h4>Default Instances</h4>
</div>
<div class="checklist" id="piped-checklist">
</div>
<hr>
<div class="some-block option-block">
<h4>Custom Instances</h4>
</div>
<form id="custom-piped-instance-form">
<div class="some-block option-block">
<input id="piped-custom-instance" placeholder="https://piped.com" type="url" />
<button type="submit" class="add" id="piped-add-instance">
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
fill="currentColor">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</svg>
</button>
</div>
</form>
<div class="checklist" id="piped-custom-checklist"></div>
</div>
</section>
<script type="module" src="../init.js"></script>
<script type="module" src="./youtube.js"></script>
<script type="module" src="./invidious.js"></script>
<script type="module" src="./piped.js"></script>
<!-- <script src="../../assets/javascripts/localise.js"></script> -->
<script type="module" src="../init.js"></script>
<script type="module" src="./youtube.js"></script>
<script type="module" src="./invidious.js"></script>
<script type="module" src="./piped.js"></script>
<!-- <script src="../../assets/javascripts/localise.js"></script> -->
</body>
</html>

View File

@ -6,6 +6,7 @@ let youtubeFrontendElement = document.getElementById("youtube-frontend");
let invidiousDivElement = document.getElementById("invidious")
let pipedDivElement = document.getElementById("piped")
let invidiousPipedDivElement = document.getElementById("invidious-piped")
function changeFrontendsSettings(frontend) {
if (frontend == 'piped') {
invidiousPipedDivElement.style.display = 'block'
@ -57,7 +58,6 @@ invidiousClearVolumeElement.addEventListener("click",
}
);
let invidiousAutoplayElement = document.getElementById("invidious-autoplay");
invidiousAutoplayElement.addEventListener("change",
(event) => youtubeHelper.setInvidiousAutoplay(event.target.options[invidiousAutoplayElement.selectedIndex].value)
@ -68,12 +68,18 @@ invidiousOnlyEmbeddedVideoElement.addEventListener("change",
(event) => youtubeHelper.setInvidiousOnlyEmbeddedVideo(event.target.checked)
);
let alwaysUsePreferredElement = document.getElementById("always-use-preferred")
alwaysUsePreferredElement.addEventListener("change",
(event) => youtubeHelper.setAlwaysusePreferred(event.target.checked)
);
youtubeHelper.init().then(() => {
disableYoutubeElement.checked = !youtubeHelper.getDisableYoutube();
invidiousThemeElement.checked = youtubeHelper.getInvidiousTheme();
invidiousVolumeElement.value = youtubeHelper.getInvidiousVolume();
invidiousVolumeValueElement.textContent = `${youtubeHelper.getInvidiousVolume()}%`;
invidiousOnlyEmbeddedVideoElement.checked = youtubeHelper.getInvidiousOnlyEmbeddedVideo();
alwaysUsePreferredElement.checked = youtubeHelper.getAlwaysusePreferred();
invidiousAutoplayElement.checked = youtubeHelper.getInvidiousAutoplay();
let frontend = youtubeHelper.getFrontend();
youtubeFrontendElement.value = frontend;