|
|
@ -54,46 +54,6 @@ if (manifest == 2) |
|
|
|
} |
|
|
|
}, filts, ['blocking', 'responseHeaders', ...(execution_mode == "chrome_api" ? ['extraHeaders' as 'blocking'] : [])]); |
|
|
|
|
|
|
|
const snooze = (n: number) => new Promise<void>((_) => setTimeout(_, n)); |
|
|
|
|
|
|
|
async function deserialize(src: any): Promise<any> { |
|
|
|
if (typeof src != "object") |
|
|
|
return src; |
|
|
|
switch (src.cls) { |
|
|
|
case 'FormData': { |
|
|
|
const ret = new FormData(); |
|
|
|
for (const [key, items] of src.value) { |
|
|
|
for (const item of items) { |
|
|
|
ret.append(key, await deserialize(item)); |
|
|
|
} |
|
|
|
} |
|
|
|
return ret; |
|
|
|
} |
|
|
|
case 'File': { |
|
|
|
if ('brave' in navigator) |
|
|
|
await snooze(1000); |
|
|
|
return new File([await (await fetch(src.value)).blob()], src.name, { |
|
|
|
lastModified: src.lastModified, |
|
|
|
type: src.type |
|
|
|
}); |
|
|
|
} |
|
|
|
case 'Blob': { |
|
|
|
if ('brave' in navigator) |
|
|
|
await snooze(1000); |
|
|
|
return new Blob([await (await fetch(src.value)).blob()], { |
|
|
|
type: src.type |
|
|
|
}); |
|
|
|
} |
|
|
|
case 'Object': { |
|
|
|
const ret = {} as any; |
|
|
|
for (const prop in src.value) { |
|
|
|
ret[prop] = await deserialize(src.value[prop]); |
|
|
|
} |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async function bravedeserialize(src: any): Promise<any> { |
|
|
|
if (typeof src != "object") |
|
|
|
return src; |
|
|
@ -108,16 +68,12 @@ async function bravedeserialize(src: any): Promise<any> { |
|
|
|
return ret; |
|
|
|
} |
|
|
|
case 'File': { |
|
|
|
if ('brave' in navigator) |
|
|
|
await snooze(1000); |
|
|
|
return new File([src.value], src.name, { |
|
|
|
lastModified: src.lastModified, |
|
|
|
type: src.type |
|
|
|
}); |
|
|
|
} |
|
|
|
case 'Blob': { |
|
|
|
if ('brave' in navigator) |
|
|
|
await snooze(1000); |
|
|
|
return new Blob([src.value], { |
|
|
|
type: src.type |
|
|
|
}); |
|
|
|