Added onlyNotEmbedded feature #37

This commit is contained in:
ManeraKai 2022-02-14 22:54:33 +03:00
parent 2a1c3ea554
commit 2d4b21772a
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
14 changed files with 36 additions and 28 deletions

View File

@ -43,7 +43,7 @@
"message": "Videos immer durch Invidious-Proxy leiten",
"description": "Label for 'Always proxy videos through Invidious' option (options)."
},
"invidiousOnlyEmbeddedVideo": {
"OnlyEmbeddedVideo": {
"message": "Nur eingebettete Videos zu Invidious weiterleiten",
"description": "Label for 'Only redirect embedded video to Invidious' option (options)."
},

View File

@ -83,7 +83,7 @@
"message": "Always proxy videos through Invidious",
"description": "Label for 'Always proxy videos through Invidious' option (options)."
},
"invidiousOnlyEmbeddedVideo": {
"OnlyEmbeddedVideo": {
"message": "Only redirect embedded video to Invidious",
"description": "Label for 'Only redirect embedded video to Invidious' option (options)."
},

View File

@ -75,7 +75,7 @@
"message": "Siempre usar el proxy de Invidious para videos",
"description": "Etiqueta para la opción de 'Siempre usar el proxy de Invidious para videos' (opciones)."
},
"invidiousOnlyEmbeddedVideo": {
"OnlyEmbeddedVideo": {
"message": "Solo redirigir los videos incrustados a Invidious",
"description": "Etiqueta para la opción de 'Solo redirigir los videos incrustados a Invidious' (opciones)."
},

View File

@ -43,7 +43,7 @@
"message": "Toujours transiter par proxy les vidéos via Invidious",
"description": "Libellé pour l'option 'Toujours transiter par proxy les vidéos via Invidious' (options)."
},
"invidiousOnlyEmbeddedVideo": {
"OnlyEmbeddedVideo": {
"message": "Rediriger uniquement les vidéos intégrées vers Invidious",
"description": "Libellé pour l'option 'Rediriger uniquement les vidéos intégrées vers Invidious' (options)."
},

View File

@ -67,7 +67,7 @@
"message": "Usa sempre il proxy per i video su Invidious",
"description": "Label for 'Always proxy videos through Invidious' option (options)."
},
"invidiousOnlyEmbeddedVideo": {
"OnlyEmbeddedVideo": {
"message": "Reindirizza solo i video incorporati verso Invidious",
"description": "Label for 'Only redirect embedded video to Invidious' option (options)."
},

View File

@ -43,7 +43,7 @@
"message": "Zawsze buforuj i wyświetlaj odnośniki wideo z YouTube poprzez Invidious",
"description": "Etykieta dla opcji 'Zawsze buforuj i wyświetlaj odnośniki wideo poprzez Invidious'."
},
"invidiousOnlyEmbeddedVideo": {
"OnlyEmbeddedVideo": {
"message": "Jedynie przekieruj odnośniki wideo do instancji Invidious",
"description": "Etykieta dla opcji 'Jedynie przekieruj odnośniki wideo do instancji Invidious'."
},

View File

@ -71,7 +71,7 @@
"message": "Всегда проксировать видео через Invidious",
"description": "Название настройки для 'Всегда проксировать видео через Invidious' (в настройках)."
},
"invidiousOnlyEmbeddedVideo": {
"OnlyEmbeddedVideo": {
"message": "Перенаправлять только встроенные видео на Invidious",
"description": "Название настройки для 'Перенаправлять только встроенные видео на Invidious' (в настройках)."
},

View File

@ -59,7 +59,7 @@
"message": "Videoları her zaman Invidious üzerinden geçir",
"description": "'Videoları her zaman Invidious üzerinden geçir' seçeneği için etiket (seçenekler)."
},
"invidiousOnlyEmbeddedVideo": {
"OnlyEmbeddedVideo": {
"message": "Sadece siteye gömülü videoları Invidious'a yönlendir",
"description": "'Sadece siteye gömülü videoları Invidious'a yönlendir' seçeneği için etiket (seçenekler)."
},

View File

@ -43,7 +43,7 @@
"message": "使用 Invidious 时始终使用视频代理",
"description": "Label for 'Always proxy videos through Invidious' option (options)."
},
"invidiousOnlyEmbeddedVideo": {
"OnlyEmbeddedVideo": {
"message": "只重定向嵌入视频至 Invidious",
"description": "Label for 'Only redirect embedded video to Invidious' option (options)."
},

View File

@ -17,7 +17,7 @@ browser.storage.sync.get(
"invidiousAlwaysProxy",
"invidiousVideoQuality",
"invidiousDarkMode",
"invidiousOnlyEmbeddedVideo",
"OnlyEmbeddedVideo",
"invidiousVolume",
"invidiousPlayerStyle",
"invidiousSubtitles",

View File

@ -125,13 +125,13 @@ function setInvidiousAlwaysProxy(val) {
}
const getInvidiousAlwaysProxy = () => invidiousAlwaysProxy;
let invidiousOnlyEmbeddedVideo;
function setInvidiousOnlyEmbeddedVideo(val) {
invidiousOnlyEmbeddedVideo = val;
browser.storage.sync.set({ invidiousOnlyEmbeddedVideo })
console.log("invidiousOnlyEmbeddedVideo: ", invidiousOnlyEmbeddedVideo)
let OnlyEmbeddedVideo;
function setOnlyEmbeddedVideo(val) {
OnlyEmbeddedVideo = val;
browser.storage.sync.set({ OnlyEmbeddedVideo })
console.log("OnlyEmbeddedVideo: ", OnlyEmbeddedVideo)
}
const getInvidiousOnlyEmbeddedVideo = () => invidiousOnlyEmbeddedVideo;
const getOnlyEmbeddedVideo = () => OnlyEmbeddedVideo;
let invidiousVideoQuality;
function setInvidiousVideoQuality(val) {
@ -265,7 +265,7 @@ async function init() {
"invidiousTheme",
"persistInvidiousPrefs",
"disableYoutube",
"invidiousOnlyEmbeddedVideo",
"OnlyEmbeddedVideo",
"invidiousVolume",
"invidiousPlayerStyle",
"invidiousSubtitles",
@ -285,7 +285,7 @@ async function init() {
disableYoutube = result.disableYoutube ?? false;
invidiousAlwaysProxy = result.invidiousAlwaysProxy ?? 'DEFAULT';
invidiousOnlyEmbeddedVideo = result.invidiousOnlyEmbeddedVideo ?? false;
OnlyEmbeddedVideo = result.OnlyEmbeddedVideo ?? 'both';
invidiousVideoQuality = result.invidiousVideoQuality ?? 'DEFAULT';
invidiousTheme = result.invidiousTheme ?? 'DEFAULT';
invidiousVolume = result.invidiousVolume ?? '--';
@ -319,6 +319,8 @@ function invidiousInitCookies(tabId) {
function redirect(url, type) {
console.log("type", type);
if (frontend == 'freeTube' && type === "main_frame")
return `freetube://${url}`;
@ -328,7 +330,8 @@ function redirect(url, type) {
if (instancesList.length === 0) return null;
let randomInstance = commonHelper.getRandomInstance(instancesList);
if (invidiousOnlyEmbeddedVideo && type !== "sub_frame") return null;
if (OnlyEmbeddedVideo == 'onlyEmbedded' && type !== "sub_frame") return null
if (OnlyEmbeddedVideo == 'onlyNotEmbedded' && type !== "main_frame") return null;
if (invidiousAlwaysProxy != "DEFAULT") url.searchParams.append("local", invidiousAlwaysProxy);
if (invidiousVideoQuality != "DEFAULT") url.searchParams.append("quality", invidiousVideoQuality);
@ -346,7 +349,8 @@ function redirect(url, type) {
if (instancesList.length === 0) return null;
let randomInstance = commonHelper.getRandomInstance(instancesList);
if (invidiousOnlyEmbeddedVideo && type !== "sub_frame") return null;
if (OnlyEmbeddedVideo == 'onlyEmbedded' && type !== "sub_frame") return null
if (OnlyEmbeddedVideo == 'onlyNotEmbedded' && type !== "main_frame") return null;
if (invidiousTheme != "DEFAULT") url.searchParams.append("theme", invidiousTheme);
if (invidiousVolume != "--") url.searchParams.append("volume", invidiousVolume / 100);
@ -377,8 +381,8 @@ export default {
setInvidiousAlwaysProxy,
getInvidiousAlwaysProxy,
setInvidiousOnlyEmbeddedVideo,
getInvidiousOnlyEmbeddedVideo,
setOnlyEmbeddedVideo,
getOnlyEmbeddedVideo,
setInvidiousVideoQuality,
getInvidiousVideoQuality,

View File

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

View File

@ -128,7 +128,11 @@
<div id="invidious-piped">
<div class="some-block option-block">
<h4>Only Redirect Embedded-Video</h4>
<input id="only-embed" type="checkbox" checked />
<select id="only-embed">
<option value="both">both</option>
<option value="onlyEmbedded">Only Embedded</option>
<option value="onlyNotEmbedded">Only Not Embedded</option>
</select>
</div>
<div class="some-block option-block">

View File

@ -63,9 +63,9 @@ invidiousAutoplayElement.addEventListener("change",
(event) => youtubeHelper.setInvidiousAutoplay(event.target.options[invidiousAutoplayElement.selectedIndex].value)
);
let invidiousOnlyEmbeddedVideoElement = document.getElementById("only-embed");
invidiousOnlyEmbeddedVideoElement.addEventListener("change",
(event) => youtubeHelper.setInvidiousOnlyEmbeddedVideo(event.target.checked)
let OnlyEmbeddedVideoElement = document.getElementById("only-embed");
OnlyEmbeddedVideoElement.addEventListener("change",
(event) => youtubeHelper.setOnlyEmbeddedVideo(event.target.options[OnlyEmbeddedVideoElement.selectedIndex].value)
);
let alwaysUsePreferredElement = document.getElementById("always-use-preferred")
@ -78,7 +78,7 @@ youtubeHelper.init().then(() => {
invidiousThemeElement.checked = youtubeHelper.getInvidiousTheme();
invidiousVolumeElement.value = youtubeHelper.getInvidiousVolume();
invidiousVolumeValueElement.textContent = `${youtubeHelper.getInvidiousVolume()}%`;
invidiousOnlyEmbeddedVideoElement.checked = youtubeHelper.getInvidiousOnlyEmbeddedVideo();
OnlyEmbeddedVideoElement.value = youtubeHelper.getOnlyEmbeddedVideo();
alwaysUsePreferredElement.checked = youtubeHelper.getAlwaysusePreferred();
invidiousAutoplayElement.checked = youtubeHelper.getInvidiousAutoplay();
let frontend = youtubeHelper.getFrontend();