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

Function injectStaticStyle

src/inject/dynamic-theme/index.ts:92–100  ·  view source on GitHub ↗
(style: HTMLStyleElement, prevNode: Node | null, watchAlias: string, callback?: () => void)

Source from the content-addressed store, hash-verified

90}
91
92function injectStaticStyle(style: HTMLStyleElement, prevNode: Node | null, watchAlias: string, callback?: () => void) {
93 const mode = getStyleInjectionMode();
94 if (mode === 'next') {
95 document.head.insertBefore(style, prevNode ? prevNode.nextSibling : document.head.firstChild);
96 setupNodePositionWatcher(style, watchAlias, callback);
97 } else if (mode === 'away') {
98 injectStyleAway(style);
99 }
100}
101
102const scheduleInversionStyleUpdate = throttle(() => {
103 const invertStyle = document.head?.querySelector<HTMLStyleElement>('.darkreader--invert');

Callers 1

Calls 3

getStyleInjectionModeFunction · 0.90
injectStyleAwayFunction · 0.90
setupNodePositionWatcherFunction · 0.85

Tested by

no test coverage detected