Merge pull request #139 from DeepDoge/master

Little clean up and fixes
This commit is contained in:
kodxana 2022-10-06 19:01:02 +02:00 committed by GitHub
commit 8c26ae0872
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 23 deletions

View file

@ -70,22 +70,18 @@ export function resetProfileSettings() {
async function apiRequest<T extends object>(method: 'GET' | 'POST', pathname: string, data: T) {
const settings = await getExtensionSettingsAsync()
/* const urlResolverSettings = ytUrlResolversSettings[settings.urlResolver]
if (!urlResolverSettings.signRequest) throw new Error() */
const url = new URL(ytUrlResolversSettings.madiatorFinder.href/* urlResolverSettings.href */)
const url = new URL(ytUrlResolversSettings.madiatorFinder.href)
url.pathname = path.join(url.pathname, pathname)
url.searchParams.set('data', JSON.stringify(data))
if (true/* requiresSignature */) {
if (!settings.privateKey || !settings.publicKey)
throw new Error('There is no profile.')
if (!settings.privateKey || !settings.publicKey)
throw new Error('There is no profile.')
url.searchParams.set('keys', JSON.stringify({
signature: await sign(url.searchParams.toString(), settings.privateKey!),
publicKey: settings.publicKey
}))
}
url.searchParams.set('keys', JSON.stringify({
signature: await sign(url.searchParams.toString(), settings.privateKey!),
publicKey: settings.publicKey
}))
const respond = await fetch(url.href, { method })

View file

@ -75,7 +75,6 @@ async function get(id: string): Promise<string | null | undefined> {
await clearExpired()
return undefined
}
console.log('cache found', id, response.value)
return response.value
}

View file

@ -1,6 +1,5 @@
#popup {
width: 40em;
max-width: 100%;
overflow: hidden;
margin: auto;
}
@ -28,18 +27,12 @@ section {
gap: .75em;
}
section>label {
label {
font-size: 1.75em;
font-weight: bold;
text-align: center;
}
section>b {
display: block;
width: 100%;
text-align: left;
}
section>* {
padding: 0 1rem;
}

View file

@ -20,7 +20,6 @@ chrome.runtime.onMessage.addListener(({ method, data }, sender, sendResponse) =>
const params: Parameters<typeof resolveById> = JSON.parse(data)
// Don't create a new Promise for same ID until on going one is over.
const promise = onGoingLbryPathnameRequest[data] ?? (onGoingLbryPathnameRequest[data] = resolveById(...params))
console.log('lbrypathname request', params, await promise)
resolve(await promise)
} catch (error) {
sendResponse(`error: ${(error as any).toString()}`)

View file

@ -231,7 +231,6 @@ import { getExtensionSettingsAsync, getSourcePlatfromSettingsFromHostname, getTa
console.error("Background error on:", params)
throw new Error(`Background error. ${response ?? ''}`)
}
console.log(response)
return response ? JSON.parse(response) : null
}