MCPcopy Index your code
hub / github.com/darkreader/darkreader / createOrUpdateCORSCopy

Function createOrUpdateCORSCopy

src/inject/dynamic-theme/style-manager.ts:326–346  ·  view source on GitHub ↗
(cssText: string, cssBasePath: string)

Source from the content-addressed store, hash-verified

324 }
325
326 async function createOrUpdateCORSCopy(cssText: string, cssBasePath: string) {
327 if (cssText) {
328 // Sometimes cross-origin stylesheets are protected from direct access
329 // so need to load CSS text and insert it into style element
330 try {
331 const fullCSSText = await replaceCSSImports(cssText, cssBasePath);
332 if (corsCopies.has(element)) {
333 if ((corsCopiesTextLengths.get(element) ?? 0) < fullCSSText.length) {
334 corsCopies.get(element)!.replaceSync(fullCSSText);
335 corsCopiesTextLengths.set(element, fullCSSText.length);
336 }
337 } else {
338 const corsCopy = new CSSStyleSheet();
339 corsCopy.replaceSync(fullCSSText);
340 corsCopies.set(element, corsCopy);
341 }
342 } catch (err) {
343 logWarn(err);
344 }
345 }
346 }
347
348 function details(options: detailsArgument) {
349 const rules = getRulesSync();

Callers 2

manageStyleFunction · 0.85
getRulesAsyncFunction · 0.85

Calls 5

logWarnFunction · 0.90
replaceCSSImportsFunction · 0.85
hasMethod · 0.65
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected