@@ -199,12 +199,12 @@ chrome.runtime.onConnect.addListener(port => {
199
199
return true ;
200
200
case 'launchContentScript' :
201
201
// !!! in Manifest Version 3 this will need to be changed to the commented out code below !!!
202
- // chrome.scripting.executeScript({
203
- // target: { tabId },
204
- // files: ['bundles/content.bundle.js'],
205
- // });
202
+ chrome . scripting . executeScript ( {
203
+ target : { tabId } ,
204
+ files : [ 'bundles/content.bundle.js' ] ,
205
+ } ) ;
206
206
// This line below will need to be removed
207
- chrome . tabs . executeScript ( tabId , { file : 'bundles/content.bundle.js' } ) ;
207
+ // chrome.tabs.executeScript(tabId, { file: 'bundles/content.bundle.js' });
208
208
return true ;
209
209
case 'jumpToSnap' :
210
210
chrome . tabs . sendMessage ( tabId , msg ) ;
@@ -282,20 +282,34 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
282
282
// This injects a script into the app that you're testing Reactime on,
283
283
// so that Reactime's backend files can communicate with the app's DOM.
284
284
case 'injectScript' : {
285
- chrome . tabs . executeScript ( tabId , {
286
- code : `
287
- // Function will attach script to the dom
288
- const injectScript = (file, tag) => {
289
- const htmlBody = document.getElementsByTagName(tag)[0];
290
- const script = document.createElement('script');
291
- script.setAttribute('type', 'text/javascript');
292
- script.setAttribute('src', file);
293
- document.title= ${ tabId } + '-' + document.title
294
- htmlBody.appendChild(script);
295
- };
296
- injectScript(chrome.runtime.getURL('bundles/backend.bundle.js'), 'body');
297
- ` ,
285
+ chrome . scripting . executeScript ( {
286
+ target : { tabId } ,
287
+ func : ( ) => {
288
+ const injectScript = ( file , tag ) => {
289
+ const htmlBody = document . getElementsByTagName ( tag ) [ 0 ] ;
290
+ const script = document . createElement ( 'script' ) ;
291
+ script . setAttribute ( 'type' , 'text/javascript' ) ;
292
+ script . setAttribute ( 'src' , file ) ;
293
+ document . title = tabId + '-' + document . title ;
294
+ htmlBody . appendChild ( script ) ;
295
+ } ;
296
+ injectScript ( chrome . runtime . getURL ( 'bundles/backend.bundle.js' ) , 'body' ) ;
297
+ } ,
298
298
} ) ;
299
+ // chrome.tabs.executeScript(tabId, {
300
+ // code: `
301
+ // // Function will attach script to the dom
302
+ // const injectScript = (file, tag) => {
303
+ // const htmlBody = document.getElementsByTagName(tag)[0];
304
+ // const script = document.createElement('script');
305
+ // script.setAttribute('type', 'text/javascript');
306
+ // script.setAttribute('src', file);
307
+ // document.title=${tabId} + '-' + document.title
308
+ // htmlBody.appendChild(script);
309
+ // };
310
+ // injectScript(chrome.runtime.getURL('bundles/backend.bundle.js'), 'body');
311
+ // `,
312
+ // });
299
313
break ;
300
314
}
301
315
case 'recordSnap' : {
0 commit comments