MCPcopy
hub / github.com/darkreader/darkreader / modify

Method modify

src/inject/dynamic-theme/variables.ts:292–316  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

290 return (theme) => {
291 const unknownVars = new Set<string>();
292 const modify = () => {
293 const variableReplaced = replaceCSSVariablesNames(
294 sourceValue,
295 (v) => {
296 if (this.isVarType(v, VAR_TYPE_BG_COLOR)) {
297 return wrapBgColorVariableName(v);
298 }
299 if (this.isVarType(v, VAR_TYPE_BG_IMG)) {
300 return wrapBgImgVariableName(v);
301 }
302 unknownVars.add(v);
303 return v;
304 },
305 (fallback) => tryModifyBgColor(fallback, theme),
306 );
307 // Check if the property is box-shadow and if so, do a pass-through to modify the shadow.
308 if (property === 'box-shadow') {
309 const shadowModifier = getShadowModifierWithInfo(variableReplaced)!;
310 const modifiedShadow = shadowModifier(theme);
311 if (modifiedShadow.unparsableMatchesLength !== modifiedShadow.matchesLength) {
312 return modifiedShadow.result;
313 }
314 }
315 return variableReplaced;
316 };
317
318 const modified = modify();
319 if (unknownVars.size > 0) {

Callers

nothing calls this directly

Calls 7

isVarTypeMethod · 0.95
replaceCSSVariablesNamesFunction · 0.85
wrapBgColorVariableNameFunction · 0.85
wrapBgImgVariableNameFunction · 0.85
tryModifyBgColorFunction · 0.85
addMethod · 0.80

Tested by

no test coverage detected