MCPcopy Create free account
hub / github.com/darkreader/darkreader / canInjectScript

Function canInjectScript

src/background/utils/extension-api.ts:5–41  ·  view source on GitHub ↗
(url: string | null | undefined)

Source from the content-addressed store, hash-verified

3import {isPDF} from '../../utils/url';
4
5export function canInjectScript(url: string | null | undefined): boolean {
6 if (url === 'about:blank') {
7 return false;
8 }
9 if (isFirefox) {
10 return Boolean(url
11 && !url.startsWith('about:')
12 && !url.startsWith('moz')
13 && !url.startsWith('view-source:')
14 && !url.startsWith('resource:')
15 && !url.startsWith('chrome:')
16 && !url.startsWith('jar:')
17 && !url.startsWith('https://addons.mozilla.org/')
18 && !isPDF(url)
19 );
20 }
21 if (isEdge) {
22 return Boolean(url
23 && !url.startsWith('chrome')
24 && !url.startsWith('data')
25 && !url.startsWith('devtools')
26 && !url.startsWith('edge')
27 && !url.startsWith('https://chrome.google.com/webstore')
28 && !url.startsWith('https://chromewebstore.google.com/')
29 && !url.startsWith('https://microsoftedge.microsoft.com/addons')
30 && !url.startsWith('view-source')
31 );
32 }
33 return Boolean(url
34 && !url.startsWith('chrome')
35 && !url.startsWith('https://chrome.google.com/webstore')
36 && !url.startsWith('https://chromewebstore.google.com/')
37 && !url.startsWith('data')
38 && !url.startsWith('devtools')
39 && !url.startsWith('view-source')
40 );
41}
42
43export async function readSyncStorage<T extends {[key: string]: any}>(defaults: T): Promise<T | null> {
44 return new Promise<T | null>((resolve) => {

Callers 3

updateContentScriptMethod · 0.90
listenFunction · 0.90
getTabInfoMethod · 0.90

Calls 1

isPDFFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…