🍣 bug fixes

This commit is contained in:
Shiba 2022-08-09 16:49:45 +00:00
parent 619d66d6aa
commit 4295dbe1fe

View file

@ -246,16 +246,18 @@ import { getExtensionSettingsAsync, getSourcePlatfromSettingsFromHostname, getTa
let urlHrefCache: string | null = null
while (true) {
await sleep(500)
const url: URL = new URL(location.href);
const url: URL = new URL(location.href)
await (async () => {
const source = await getSourceByUrl(new URL(location.href))
if (!source) continue
if (!source) return
try {
if (settings.redirect) {
const target = (await getTargetsBySources(source))[source.id]
if (!target) continue
if (url.href === urlHrefCache) continue
if (!target) return
console.log(url.href, urlHrefCache)
if (url.href === urlHrefCache) return
const lbryURL = getLbryUrlByTarget(target)
@ -274,6 +276,7 @@ import { getExtensionSettingsAsync, getSourcePlatfromSettingsFromHostname, getTa
location.replace(lbryURL)
}
else {
console.log('open', lbryURL.href)
openNewTab(lbryURL, document.hasFocus())
if (window.history.length === 1) window.close()
@ -337,6 +340,8 @@ import { getExtensionSettingsAsync, getSourcePlatfromSettingsFromHostname, getTa
} catch (error) {
console.error(error)
}
})()
urlHrefCache = url.href
}