File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 11import { onConnect , onMessage , sendToTab } from 'crossmessaging' ;
2+ import getOptions from '../options/getOptions' ;
23import { MENU_DEVTOOLS } from '../../../app/constants/ContextMenus.js' ;
34let connections = { } ;
45
@@ -27,13 +28,19 @@ function parseJSON(data) {
2728}
2829
2930// Receive message from content script and relay to the devTools page
30- function messaging ( request , sender ) {
31+ function messaging ( request , sender , sendResponse ) {
3132 const tabId = sender . tab ? sender . tab . id : sender . id ;
3233 if ( tabId ) {
3334 if ( request . type === 'PAGE_UNLOADED' ) {
3435 if ( connections [ tabId ] ) connections [ tabId ] . postMessage ( naMessage ) ;
3536 return true ;
3637 }
38+ if ( request . type === 'GET_OPTIONS' ) {
39+ getOptions ( options => {
40+ sendResponse ( { options : options } ) ;
41+ } ) ;
42+ return true ;
43+ }
3744 const payload = typeof request . payload === 'string' ? parseJSON ( request . payload ) : request . payload ;
3845 if ( ! payload ) return true ;
3946 store . liftedStore . setState ( payload ) ;
Original file line number Diff line number Diff line change 33
44window . devToolsExtensionID = 'lmhkpmbekcpmknklioeibfkpmmfibljd' ;
55
6- require ( './contentScript' ) ;
7- require ( './pageScript' ) ;
6+ chrome . runtime . sendMessage ( window . devToolsExtensionID , { type : 'GET_OPTIONS' } , function ( response ) {
7+ if ( ! response . options . inject ) {
8+ const urls = response . options . urls . split ( '\n' ) . join ( '|' ) ;
9+ if ( ! location . href . match ( new RegExp ( urls ) ) ) return ;
10+ }
11+
12+ window . devToolsOptions = response . options ;
13+ require ( './contentScript' ) ;
14+ require ( './pageScript' ) ;
15+ } ) ;
Original file line number Diff line number Diff line change 11const getOptions = callback => {
2+ if ( window . devToolsExtensionID && chrome . runtime . id !== window . devToolsExtensionID ) {
3+ callback ( window . devToolsOptions ) ;
4+ return ;
5+ }
6+
27 chrome . storage . sync . get ( {
38 limit : 50 ,
49 timeout : 1 ,
You can’t perform that action at this time.
0 commit comments