MCPcopy
hub / github.com/darkreader/darkreader / shouldIgnoreImage

Function shouldIgnoreImage

src/inject/dynamic-theme/modify-css.ts:347–372  ·  view source on GitHub ↗
(selectorText: string, selectors: string[])

Source from the content-addressed store, hash-verified

345let didTryLoadCache = false;
346
347function shouldIgnoreImage(selectorText: string, selectors: string[]) {
348 if (!selectorText || selectors.length === 0) {
349 return false;
350 }
351 if (selectors.some((s) => s === '*')) {
352 return true;
353 }
354 const ruleSelectors = selectorText.split(/,\s*/g);
355 for (let i = 0; i < selectors.length; i++) {
356 const ignoredSelector = selectors[i];
357 if (ignoredSelector.startsWith('^')) {
358 const beginning = ignoredSelector.slice(1);
359 if (ruleSelectors.some((s) => s.startsWith(beginning))) {
360 return true;
361 }
362 } else if (ignoredSelector.endsWith('$')) {
363 const ending = ignoredSelector.slice(0, ignoredSelector.length - 1);
364 if (ruleSelectors.some((s) => s.endsWith(ending))) {
365 return true;
366 }
367 } else if (ruleSelectors.some((s) => s === ignoredSelector)) {
368 return true;
369 }
370 }
371 return false;
372}
373
374interface BgImageMatches {
375 type: 'url' | 'gradient';

Callers 1

getBgImageModifierFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected