MCPcopy
hub / github.com/darkreader/darkreader / formatDynamicThemeFixes

Function formatDynamicThemeFixes

src/generators/dynamic-theme.ts:34–53  ·  view source on GitHub ↗
(dynamicThemeFixes: DynamicThemeFix[])

Source from the content-addressed store, hash-verified

32}
33
34export function formatDynamicThemeFixes(dynamicThemeFixes: DynamicThemeFix[]): string {
35 const fixes = dynamicThemeFixes.slice().sort((a, b) => compareURLPatterns(a.url[0], b.url[0]));
36
37 return formatSitesFixesConfig(fixes, {
38 props: Object.values(dynamicThemeFixesCommands),
39 getPropCommandName: (prop) => Object.entries(dynamicThemeFixesCommands).find(([, p]) => p === prop)![0],
40 formatPropValue: (prop, value) => {
41 if (prop === 'css') {
42 return formatCSS(value as string);
43 }
44 return formatArray(value as string[]).trim();
45 },
46 shouldIgnoreProp: (prop, value) => {
47 if (prop === 'css') {
48 return !value;
49 }
50 return !(Array.isArray(value) && value.length > 0);
51 },
52 });
53}
54
55export function getDynamicThemeFixesFor(url: string, text: string, index: SiteFixesIndex, enabledForPDF: boolean): DynamicThemeFix[] | null {
56 const fixes = getSitesFixesFor(url, text, index, parseDynamicThemeFixes);

Callers 3

config.tests.tsFile · 0.90

Calls 4

compareURLPatternsFunction · 0.90
formatSitesFixesConfigFunction · 0.90
formatCSSFunction · 0.90
formatArrayFunction · 0.90

Tested by

no test coverage detected