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

Function addFilterSelector

src/inject/dynamic-theme/selectors.ts:9–34  ·  view source on GitHub ↗
(selector: string, type: keyof typeof filterSelectors)

Source from the content-addressed store, hash-verified

7};
8
9export function addFilterSelector(selector: string, type: keyof typeof filterSelectors) {
10 if (!selector) {
11 return;
12 }
13 const selectors = filterSelectors[type];
14 let changed = false;
15 selector.split(',').forEach((part) => {
16 const s = part.trim();
17 if (!s || selectors.has(s)) {
18 return;
19 }
20 for (const existing of selectors) {
21 if (isSelectorWithin(s, existing)) {
22 return;
23 }
24 }
25 for (const existing of [...selectors]) {
26 if (isSelectorWithin(existing, s)) {
27 selectors.delete(existing);
28 }
29 }
30 selectors.add(s);
31 changed = true;
32 });
33 return changed;
34}
35
36export function makeSelectorEmpty(selector: string) {
37 selector = selector.trim();

Callers 2

index.tsFile · 0.90
pushFilterSelectorFunction · 0.85

Calls 3

isSelectorWithinFunction · 0.85
addMethod · 0.80
hasMethod · 0.65

Tested by

no test coverage detected