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

View File

@ -83,7 +83,7 @@
"message": "Always proxy videos through Invidious", "message": "Always proxy videos through Invidious",
"description": "Label for 'Always proxy videos through Invidious' option (options)." "description": "Label for 'Always proxy videos through Invidious' option (options)."
}, },
"invidiousOnlyEmbeddedVideo": { "OnlyEmbeddedVideo": {
"message": "Only redirect embedded video to Invidious", "message": "Only redirect embedded video to Invidious",
"description": "Label for 'Only redirect embedded video to Invidious' option (options)." "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", "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)." "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", "message": "Solo redirigir los videos incrustados a Invidious",
"description": "Etiqueta para la opción de 'Solo redirigir los videos incrustados a Invidious' (opciones)." "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", "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)." "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", "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)." "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", "message": "Usa sempre il proxy per i video su Invidious",
"description": "Label for 'Always proxy videos through Invidious' option (options)." "description": "Label for 'Always proxy videos through Invidious' option (options)."
}, },
"invidiousOnlyEmbeddedVideo": { "OnlyEmbeddedVideo": {
"message": "Reindirizza solo i video incorporati verso Invidious", "message": "Reindirizza solo i video incorporati verso Invidious",
"description": "Label for 'Only redirect embedded video to Invidious' option (options)." "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", "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'." "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", "message": "Jedynie przekieruj odnośniki wideo do instancji Invidious",
"description": "Etykieta dla opcji '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", "message": "Всегда проксировать видео через Invidious",
"description": "Название настройки для 'Всегда проксировать видео через Invidious' (в настройках)." "description": "Название настройки для 'Всегда проксировать видео через Invidious' (в настройках)."
}, },
"invidiousOnlyEmbeddedVideo": { "OnlyEmbeddedVideo": {
"message": "Перенаправлять только встроенные видео на Invidious", "message": "Перенаправлять только встроенные видео на Invidious",
"description": "Название настройки для 'Перенаправлять только встроенные видео на Invidious' (в настройках)." "description": "Название настройки для 'Перенаправлять только встроенные видео на Invidious' (в настройках)."
}, },

View File

@ -59,7 +59,7 @@
"message": "Videoları her zaman Invidious üzerinden geçir", "message": "Videoları her zaman Invidious üzerinden geçir",
"description": "'Videoları her zaman Invidious üzerinden geçir' seçeneği için etiket (seçenekler)." "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", "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)." "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 时始终使用视频代理", "message": "使用 Invidious 时始终使用视频代理",
"description": "Label for 'Always proxy videos through Invidious' option (options)." "description": "Label for 'Always proxy videos through Invidious' option (options)."
}, },
"invidiousOnlyEmbeddedVideo": { "OnlyEmbeddedVideo": {
"message": "只重定向嵌入视频至 Invidious", "message": "只重定向嵌入视频至 Invidious",
"description": "Label for 'Only redirect embedded video to Invidious' option (options)." "description": "Label for 'Only redirect embedded video to Invidious' option (options)."
}, },

View File

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

View File

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

View File

@ -47,7 +47,7 @@ browser.webRequest.onBeforeRequest.addListener(
if (exceptionsHelper.isException(url)) newUrl = null; 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); else if (twitterHelper.isTwitter(url)) newUrl = twitterHelper.redirect(url, initiator);

View File

@ -128,7 +128,11 @@
<div id="invidious-piped"> <div id="invidious-piped">
<div class="some-block option-block"> <div class="some-block option-block">
<h4>Only Redirect Embedded-Video</h4> <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>
<div class="some-block option-block"> <div class="some-block option-block">

View File

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