|
1 | 1 | // Import snapshots from "../app/components/snapshots". |
2 | | -import 'core-js'; |
| 2 | +// import 'core-js'; |
3 | 3 |
|
4 | | -console.log('Hello from line 4'); |
5 | 4 | // Store ports in an array. |
6 | 5 | const portsArr = []; |
7 | 6 | const reloaded = {}; |
@@ -288,35 +287,22 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { |
288 | 287 | // so that Reactime's backend files can communicate with the app's DOM. |
289 | 288 | case 'injectScript': { |
290 | 289 | console.log('Hello from line 287'); |
| 290 | + |
| 291 | + const injectScript = (file, tabId) => { |
| 292 | + const htmlBody = document.getElementsByTagName('body')[0]; |
| 293 | + const script = document.createElement('script'); |
| 294 | + script.setAttribute('type', 'text/javascript'); |
| 295 | + script.setAttribute('src', file); |
| 296 | + // eslint-disable-next-line prefer-template |
| 297 | + document.title = tabId + '-' + document.title; |
| 298 | + htmlBody.appendChild(script); |
| 299 | + }; |
| 300 | + |
291 | 301 | chrome.scripting.executeScript({ |
292 | 302 | target: { tabId }, |
293 | | - func: tab => { |
294 | | - const injectScript = (file, tag) => { |
295 | | - const htmlBody = document.getElementsByTagName(tag)[0]; |
296 | | - const script = document.createElement('script'); |
297 | | - script.setAttribute('type', 'text/javascript'); |
298 | | - script.setAttribute('src', file); |
299 | | - document.title = tab + '-' + document.title; |
300 | | - htmlBody.appendChild(script); |
301 | | - }; |
302 | | - injectScript(chrome.runtime.getURL('bundles/backend.bundle.js'), 'body'); |
303 | | - }, |
304 | | - args: [tabId], |
| 303 | + function: injectScript, |
| 304 | + args: [chrome.runtime.getURL('bundles/backend.bundle.js'), tabId], |
305 | 305 | }); |
306 | | - // chrome.tabs.executeScript(tabId, { |
307 | | - // code: ` |
308 | | - // // Function will attach script to the dom |
309 | | - // const injectScript = (file, tag) => { |
310 | | - // const htmlBody = document.getElementsByTagName(tag)[0]; |
311 | | - // const script = document.createElement('script'); |
312 | | - // script.setAttribute('type', 'text/javascript'); |
313 | | - // script.setAttribute('src', file); |
314 | | - // document.title=${tabId} + '-' + document.title |
315 | | - // htmlBody.appendChild(script); |
316 | | - // }; |
317 | | - // injectScript(chrome.runtime.getURL('bundles/backend.bundle.js'), 'body'); |
318 | | - // `, |
319 | | - // }); |
320 | 306 | break; |
321 | 307 | } |
322 | 308 | case 'recordSnap': { |
@@ -442,6 +428,7 @@ chrome.runtime.onInstalled.addListener(() => { |
442 | 428 | title: 'Reactime', |
443 | 429 | contexts: ['page', 'selection', 'image', 'link'], |
444 | 430 | }); |
| 431 | + console.log('Context Menu Created'); |
445 | 432 | }); |
446 | 433 |
|
447 | 434 | // when context menu is clicked, listen for the menuItemId, |
|
0 commit comments