File tree 3 files changed +11
-10
lines changed
3 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { send } from './runtime.js';
3
3
import { index as v4 } from './svelte-4.js' ;
4
4
import { serialize } from './utils.js' ;
5
5
6
- // @ts -ignore - for the app to call with `eval`
6
+ // @ts -ignore - https://developer.chrome.com/docs/extensions/how-to/devtools/extend-devtools#selected-element
7
7
window [ '#SvelteDevTools' ] = {
8
8
/**
9
9
* @param {string } id
Original file line number Diff line number Diff line change @@ -56,6 +56,8 @@ function courier(tabId, changed) {
56
56
57
57
chrome . scripting . executeScript ( {
58
58
target : { tabId } ,
59
+
60
+ // ensures we're listening to the events before they're dispatched
59
61
injectImmediately : true ,
60
62
61
63
// no lexical context, `func` is serialized and deserialized.
@@ -69,15 +71,6 @@ function courier(tabId, changed) {
69
71
// - chrome.i18n
70
72
// - chrome.runtime
71
73
func : ( ) => {
72
- const source = chrome . runtime . getURL ( '/courier.js' ) ;
73
- if ( document . querySelector ( `script[src="${ source } "]` ) ) return ;
74
-
75
- // attach script manually instead of declaring through `files`
76
- // because `detail` in the dispatched custom events is `null`
77
- const script = document . createElement ( 'script' ) ;
78
- script . setAttribute ( 'src' , source ) ;
79
- document . head . appendChild ( script ) ;
80
-
81
74
chrome . runtime . onMessage . addListener ( ( message , sender ) => {
82
75
if ( sender . id !== chrome . runtime . id ) return ; // unexpected sender
83
76
window . postMessage ( message ) ; // relay to content script (courier.js)
Original file line number Diff line number Diff line change 24
24
"scripts" : [" background.js" ],
25
25
"service_worker" : " background.js"
26
26
},
27
+ "content_scripts" : [
28
+ {
29
+ "matches" : [" <all_urls>" ],
30
+ "js" : [" courier.js" ],
31
+ "run_at" : " document_start" ,
32
+ "world" : " MAIN"
33
+ }
34
+ ],
27
35
"devtools_page" : " register.html" ,
28
36
"host_permissions" : [" *://*/*" ],
29
37
"permissions" : [" activeTab" , " scripting" ],
You can’t perform that action at this time.
0 commit comments