MCPcopy
hub / github.com/darkreader/darkreader / tryConvertDataURLToBlobURL

Function tryConvertDataURLToBlobURL

src/inject/dynamic-theme/image.ts:382–401  ·  view source on GitHub ↗
(dataURL: string)

Source from the content-addressed store, hash-verified

380}
381
382export async function tryConvertDataURLToBlobURL(dataURL: string): Promise<string | null> {
383 if (!isBlobURLSupported) {
384 return null;
385 }
386 const hash = getHashCode(dataURL);
387 let blobURL = dataURLBlobURLs.get(hash);
388 if (blobURL) {
389 return blobURL;
390 }
391
392 let blob = tryConvertDataURLToBlobSync(dataURL);
393 if (!blob) {
394 const response = await fetch(dataURL);
395 blob = await response.blob();
396 }
397
398 blobURL = URL.createObjectURL(blob);
399 dataURLBlobURLs.set(hash, blobURL);
400 return blobURL;
401}
402
403export function cleanImageProcessingCache(): void {
404 imageManager && imageManager.stop();

Callers 1

getURLModifierFunction · 0.90

Calls 4

getHashCodeFunction · 0.90
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected