MCPcopy
hub / github.com/darkreader/darkreader / formatDetectorHints

Function formatDetectorHints

src/generators/detector-hints.ts:35–54  ·  view source on GitHub ↗
(detectorHints: DetectorHint[])

Source from the content-addressed store, hash-verified

33}
34
35export function formatDetectorHints(detectorHints: DetectorHint[]): string {
36 const fixes = detectorHints.slice().sort((a, b) => compareURLPatterns(a.url[0], b.url[0]));
37
38 return formatSitesFixesConfig(fixes, {
39 props: Object.values(detectorHintsCommands),
40 getPropCommandName: (prop) => Object.entries(detectorHintsCommands).find(([, p]) => p === prop)![0],
41 formatPropValue: (prop, value) => {
42 if (Array.isArray(value)) {
43 return formatArray(value).trim();
44 }
45 if (prop === 'noDarkTheme' || prop === 'systemTheme') {
46 return '';
47 }
48 return String(value).trim();
49 },
50 shouldIgnoreProp: (_prop, value) => {
51 return !value;
52 },
53 });
54}
55
56export function getDetectorHintsFor(url: string, text: string, index: SiteFixesIndex): DetectorHint[] | null {
57 const fixes = getSitesFixesFor(url, text, index, parseDetectorHints);

Callers 3

getDetectorHintsTextMethod · 0.90
applyDetectorHintsMethod · 0.90
config.tests.tsFile · 0.90

Calls 3

compareURLPatternsFunction · 0.90
formatSitesFixesConfigFunction · 0.90
formatArrayFunction · 0.90

Tested by

no test coverage detected