(url: string, userSettings: UserSettings, {isProtected, isInDarkList, isDarkThemeDetected}: Partial<TabInfo>, isAllowedFileSchemeAccess = true)
| 341 | } |
| 342 | |
| 343 | export 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 | |
| 373 | export function isLocalFile(url: string): boolean { |
| 374 | return Boolean(url) && url.startsWith('file:///'); |
no test coverage detected