MCPcopy
hub / github.com/darkreader/darkreader / prepareOverridesSheet

Function prepareOverridesSheet

src/inject/dynamic-theme/style-manager.ts:400–431  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

398 }
399
400 function prepareOverridesSheet(): CSSStyleSheet {
401 if (!syncStyle) {
402 createSyncStyle();
403 }
404
405 syncStylePositionWatcher && syncStylePositionWatcher.stop();
406 insertStyle();
407
408 // Firefox issue: Some websites get CSP warning,
409 // when `textContent` is not set (e.g. pypi.org).
410 // But for other websites (e.g. facebook.com)
411 // some images disappear when `textContent`
412 // is initially set to an empty string.
413 if (syncStyle!.sheet == null) {
414 syncStyle!.textContent = '';
415 }
416
417 const sheet = syncStyle!.sheet;
418
419 removeCSSRulesFromSheet(sheet!);
420
421 if (syncStylePositionWatcher) {
422 syncStylePositionWatcher.run();
423 } else if (inMode === 'next') {
424 syncStylePositionWatcher = watchForNodePosition(syncStyle!, 'prev-sibling', () => {
425 forceRenderStyle = true;
426 buildOverrides();
427 });
428 }
429
430 return syncStyle!.sheet!;
431 }
432
433 function buildOverrides() {
434 const force = forceRenderStyle;

Callers

nothing calls this directly

Calls 7

watchForNodePositionFunction · 0.90
createSyncStyleFunction · 0.85
insertStyleFunction · 0.85
removeCSSRulesFromSheetFunction · 0.85
buildOverridesFunction · 0.85
runMethod · 0.80
stopMethod · 0.65

Tested by

no test coverage detected