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