Squashed a few bugs

Closes https://github.com/libredirect/libredirect/issues/392
This commit is contained in:
BobIsMyManager 2022-07-24 16:30:41 +01:00
parent ccfcccd53e
commit a43f0a7e7f
7 changed files with 22 additions and 9 deletions

View File

@ -530,7 +530,7 @@ function switchInstance(url, disableOverride) {
...librexLokiCustomRedirects
].includes(protocolHost)) { resolve(); return; }
let instancesList;
let instancesList = [];
if (protocol == 'loki') {
if (searchFrontend == 'searx') instancesList = [...searxLokiCustomRedirects];

View File

@ -140,7 +140,7 @@ function init() {
pipedMaterialNormalCustomRedirects = r.pipedMaterialNormalCustomRedirects;
pipedMaterialTorRedirectsChecks = r.pipedMaterialTorRedirectsChecks;
pipedMaterialTorCustomRedirects = r.pipedMaterialTorCustomRedirects;
pipedMaterialI2pCustomRedirects - r.pipedMaterialI2pCustomRedirects;
pipedMaterialI2pCustomRedirects = r.pipedMaterialI2pCustomRedirects;
pipedMaterialLokiCustomRedirects = r.pipedMaterialLokiCustomRedirects;
resolve();
}
@ -198,6 +198,7 @@ function redirect(url, type, initiator, disableOverride) {
const main_frame = type === "main_frame";
const sub_frame = type === "sub_frame";
if (!sub_frame && !main_frame) return;
if (url.pathname.match(/iframe_api/) || url.pathname.match(/www-widgetapi/)) return; // Don't redirect YouTube Player API.
if (onlyEmbeddedVideo == 'onlyEmbedded' && main_frame) return;
if (onlyEmbeddedVideo == 'onlyNotEmbedded' && !main_frame) return;

View File

@ -87,6 +87,7 @@ youtube.addEventListener("change", () => {
browser.storage.local.set({
disableYoutube: !enable.checked,
youtubeEmbedFrontend: youtubeEmbedFrontend.value,
youtubeFrontend: frontend.value,
onlyEmbeddedVideo: onlyEmbeddedVideo.value
})
changeFrontendsSettings();

View File

@ -97,8 +97,10 @@
<h4 data-localise="__MSG_sendFiles__">Send Files</h4></a>
<input class="disable-sendTargets" type="checkbox"/>
</div>
<div id="current_site_divider">
<hr>
</div>
</div>
<div class="all_sites">
<div class="youtube some-block"><a class="title" href="https://youtube.com"><img src="../../assets/images/youtube-icon.png"/>
<h4 data-localise="__MSG_youtube__">YouTube</h4></a>

View File

@ -110,6 +110,8 @@ const disableImgurAllSites = allSites.getElementsByClassName("disable-imgur")[0]
const disableTiktokCurrentSite = currSite.getElementsByClassName("disable-tiktok")[0];
const disableTiktokAllSites = allSites.getElementsByClassName("disable-tiktok")[0];
const currentSiteIsFrontend = document.getElementById('current_site_divider')
browser.storage.local.get(
[
"disableTwitter",
@ -163,7 +165,10 @@ browser.storage.local.get(
let url;
try { url = new URL(tabs[0].url); }
catch { return; }
catch {
currentSiteIsFrontend.classList.add("hide")
return;
}
if (youtubeHelper.redirect(url, 'main_frame', false, true) || await youtubeHelper.switchInstance(url, 'main_frame', false, true)) {
currSite.getElementsByClassName('youtube')[0].classList.remove("hide");
@ -236,6 +241,9 @@ browser.storage.local.get(
else if (youtubeMusicHelper.redirect(url, 'main_frame', false, true)) {
currSite.getElementsByClassName('youtubeMusic')[0].classList.remove("hide");
allSites.getElementsByClassName('youtubeMusic')[0].classList.add("hide");
} else {
currentSiteIsFrontend.classList.add("hide")
console.log("This page is not an instance")
}
})
}

View File

@ -119,6 +119,7 @@ html(lang="en")
body(dir="auto")
.current_site
+services
#current_site_divider
hr
.all_sites
+services