1
/* global chrome */
2
3
-// Firefox doesn't support ExecutionWorld.MAIN yet
4
-// equivalent logic for Firefox is in prepareInjection.js
5
-const contentScriptsToInject = __IS_FIREFOX__
6
- ? [
7
- {
8
- id: '@react-devtools/proxy',
9
- js: ['build/proxy.js'],
10
- matches: ['<all_urls>'],
11
- persistAcrossSessions: true,
12
- runAt: 'document_end',
13
- },
14
- {
15
- id: '@react-devtools/file-fetcher',
16
- js: ['build/fileFetcher.js'],
17
- matches: ['<all_urls>'],
18
- persistAcrossSessions: true,
19
- runAt: 'document_end',
20
- },
21
- ]
22
- : [
23
- {
24
- id: '@react-devtools/proxy',
25
- js: ['build/proxy.js'],
26
- matches: ['<all_urls>'],
27
- persistAcrossSessions: true,
28
- runAt: 'document_end',
29
- world: chrome.scripting.ExecutionWorld.ISOLATED,
30
- },
31
- {
32
- id: '@react-devtools/file-fetcher',
33
- js: ['build/fileFetcher.js'],
34
- matches: ['<all_urls>'],
35
- persistAcrossSessions: true,
36
- runAt: 'document_end',
37
- world: chrome.scripting.ExecutionWorld.ISOLATED,
38
- },
39
- {
40
- id: '@react-devtools/hook',
41
- js: ['build/installHook.js'],
42
- matches: ['<all_urls>'],
43
- persistAcrossSessions: true,
44
- runAt: 'document_start',
45
- world: chrome.scripting.ExecutionWorld.MAIN,
46
- },
47
- {
48
- id: '@react-devtools/renderer',
49
- js: ['build/renderer.js'],
50
- matches: ['<all_urls>'],
51
- persistAcrossSessions: true,
52
- runAt: 'document_start',
53
- world: chrome.scripting.ExecutionWorld.MAIN,
54
- },
55
- ];
3
+const contentScriptsToInject = [
4
+ {
5
+ id: '@react-devtools/proxy',
6
+ js: ['build/proxy.js'],
7
+ matches: ['<all_urls>'],
8
+ persistAcrossSessions: true,
9
+ runAt: 'document_end',
10
+ world: chrome.scripting.ExecutionWorld.ISOLATED,
11
+ },
12
+ {
13
+ id: '@react-devtools/file-fetcher',
14
+ js: ['build/fileFetcher.js'],
15
+ matches: ['<all_urls>'],
16
+ persistAcrossSessions: true,
17
+ runAt: 'document_end',
18
+ world: chrome.scripting.ExecutionWorld.ISOLATED,
19
+ },
20
+ {
21
+ id: '@react-devtools/hook',
22
+ js: ['build/installHook.js'],
23
+ matches: ['<all_urls>'],
24
+ persistAcrossSessions: true,
25
+ runAt: 'document_start',
26
+ world: chrome.scripting.ExecutionWorld.MAIN,
27
+ },
28
+ {
29
+ id: '@react-devtools/renderer',
30
+ js: ['build/renderer.js'],
31
+ matches: ['<all_urls>'],
32
+ persistAcrossSessions: true,
33
+ runAt: 'document_start',
34
+ world: chrome.scripting.ExecutionWorld.MAIN,
35
+ },
36
+];
37
38
async function dynamicallyInjectContentScripts() {
39
try {
42
// This fixes registering proxy content script in incognito mode
43
await chrome.scripting.unregisterContentScripts();
44
64
- // equivalent logic for Firefox is in prepareInjection.js
65
- // Manifest V3 method of injecting content script
66
- // TODO(hoxyq): migrate Firefox to V3 manifests
45
// Note: the "world" option in registerContentScripts is only available in Chrome v102+
46
// It's critical since it allows us to directly run scripts on the "main" world on the page
47
// "document_start" allows it to run before the page's scripts