MCPcopy
hub / github.com/darkreader/darkreader / isURLEnabled

Function isURLEnabled

src/utils/url.ts:343–371  ·  view source on GitHub ↗
(url: string, userSettings: UserSettings, {isProtected, isInDarkList, isDarkThemeDetected}: Partial<TabInfo>, isAllowedFileSchemeAccess = true)

Source from the content-addressed store, hash-verified

341}
342
343export function isURLEnabled(url: string, userSettings: UserSettings, {isProtected, isInDarkList, isDarkThemeDetected}: Partial<TabInfo>, isAllowedFileSchemeAccess = true): boolean {
344 if (isLocalFile(url) && !isAllowedFileSchemeAccess) {
345 return false;
346 }
347 if (isProtected && !userSettings.enableForProtectedPages) {
348 return false;
349 }
350 // Only URL's with emails are getting here on thunderbird
351 // So we can skip the checks and just return true.
352 if (__THUNDERBIRD__) {
353 return true;
354 }
355 if (isPDF(url)) {
356 return userSettings.enableForPDF;
357 }
358 const isURLInDisabledList = isInListOptimized(url, userSettings.disabledFor);
359 const isURLInEnabledList = isInListOptimized(url, userSettings.enabledFor);
360
361 if (!userSettings.enabledByDefault) {
362 return isURLInEnabledList;
363 }
364 if (isURLInEnabledList) {
365 return true;
366 }
367 if (isInDarkList || (userSettings.detectDarkTheme && isDarkThemeDetected)) {
368 return false;
369 }
370 return !isURLInDisabledList;
371}
372
373export function isLocalFile(url: string): boolean {
374 return Boolean(url) && url.startsWith('file:///');

Callers 5

ExtensionClass · 0.90
getSiteToggleDataFunction · 0.90
FontGroupFunction · 0.90
SiteToggleGroupFunction · 0.90
url.tests.tsFile · 0.90

Calls 3

isLocalFileFunction · 0.85
isPDFFunction · 0.85
isInListOptimizedFunction · 0.85

Tested by

no test coverage detected