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

Function getRulesSync

src/inject/dynamic-theme/style-manager.ts:201–229  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

199 }
200
201 function getRulesSync(): CSSRuleList | null {
202 if (corsCopies.has(element)) {
203 logInfo('[getRulesSync] Using cors-copy.');
204 return corsCopies.get(element)!.cssRules;
205 }
206 if (containsCSSImport()) {
207 logInfo('[getRulesSync] CSSImport detected.');
208 return null;
209 }
210
211 const cssRules = safeGetSheetRules();
212 if (
213 element instanceof HTMLLinkElement &&
214 !isRelativeHrefOnAbsolutePath(element.href) &&
215 hasImports(cssRules, false)
216 ) {
217 logInfo('[getRulesSync] CSSImportRule detected on non-local href.');
218 return null;
219 }
220
221 if (hasImports(cssRules, true)) {
222 logInfo('[getRulesSync] Cross-Origin CSSImportRule detected.');
223 return null;
224 }
225
226 logInfo('[getRulesSync] Using cssRules.');
227 !cssRules && logWarn('[getRulesSync] cssRules is null, trying again.');
228 return cssRules;
229 }
230
231 function insertStyle() {
232 if (inMode === 'next') {

Callers 2

detailsFunction · 0.85
renderFunction · 0.85

Calls 8

logInfoFunction · 0.90
logWarnFunction · 0.90
containsCSSImportFunction · 0.85
safeGetSheetRulesFunction · 0.85
hasImportsFunction · 0.85
hasMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected