|
1 | 1 | // Import snapshots from "../app/components/snapshots".
|
2 |
| -import 'core-js'; |
| 2 | +// import 'core-js'; |
| 3 | + |
3 | 4 | // Store ports in an array.
|
4 | 5 | const portsArr = [];
|
5 | 6 | const reloaded = {};
|
@@ -198,13 +199,10 @@ chrome.runtime.onConnect.addListener(port => {
|
198 | 199 | tabsObj[tabId].mode.persist = payload;
|
199 | 200 | return true;
|
200 | 201 | case 'launchContentScript':
|
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 |
| - // }); |
206 |
| - // This line below will need to be removed |
207 |
| - chrome.tabs.executeScript(tabId, { file: 'bundles/content.bundle.js' }); |
| 202 | + chrome.scripting.executeScript({ |
| 203 | + target: { tabId }, |
| 204 | + files: ['bundles/content.bundle.js'], |
| 205 | + }); |
208 | 206 | return true;
|
209 | 207 | case 'jumpToSnap':
|
210 | 208 | chrome.tabs.sendMessage(tabId, msg);
|
@@ -282,19 +280,20 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
282 | 280 | // This injects a script into the app that you're testing Reactime on,
|
283 | 281 | // so that Reactime's backend files can communicate with the app's DOM.
|
284 | 282 | 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 |
| - `, |
| 283 | + const injectScript = (file, tab) => { |
| 284 | + const htmlBody = document.getElementsByTagName('body')[0]; |
| 285 | + const script = document.createElement('script'); |
| 286 | + script.setAttribute('type', 'text/javascript'); |
| 287 | + script.setAttribute('src', file); |
| 288 | + // eslint-disable-next-line prefer-template |
| 289 | + document.title = tab + '-' + document.title; |
| 290 | + htmlBody.appendChild(script); |
| 291 | + }; |
| 292 | + |
| 293 | + chrome.scripting.executeScript({ |
| 294 | + target: { tabId }, |
| 295 | + function: injectScript, |
| 296 | + args: [chrome.runtime.getURL('bundles/backend.bundle.js'), tabId], |
298 | 297 | });
|
299 | 298 | break;
|
300 | 299 | }
|
|
0 commit comments