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

Function defaultFallbackFactory

src/inject/dynamic-theme/modify-css.ts:251–264  ·  view source on GitHub ↗
(theme: Theme, {strict}: {strict: boolean})

Source from the content-addressed store, hash-verified

249type FallbackFactory = (theme: Theme, options: {strict: boolean}) => string;
250
251function defaultFallbackFactory(theme: Theme, {strict}: {strict: boolean}): string {
252 const lines: string[] = [];
253 lines.push(`html, body, ${strict ? 'body :not(iframe)' : 'body > :not(iframe)'} {`);
254 lines.push(` background-color: ${modifyBackgroundColor({r: 255, g: 255, b: 255}, theme)} !important;`);
255 lines.push(` border-color: ${modifyBorderColor({r: 64, g: 64, b: 64}, theme)} !important;`);
256 lines.push(` color: ${modifyForegroundColor({r: 0, g: 0, b: 0}, theme)} !important;`);
257 lines.push('}');
258 // MS Learn High Contrast issue
259 // https://github.com/darkreader/darkreader/issues/3618
260 lines.push(`div[style*="background-color: rgb(135, 135, 135)"] {`);
261 lines.push(` background-color: #878787 !important;`);
262 lines.push('}');
263 return lines.join('\n');
264}
265
266let fallbackFactory: FallbackFactory | null = null;
267

Callers

nothing calls this directly

Calls 3

modifyBackgroundColorFunction · 0.90
modifyBorderColorFunction · 0.90
modifyForegroundColorFunction · 0.90

Tested by

no test coverage detected