@@ -518,28 +518,28 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo) => {
518
518
} ) ;
519
519
520
520
// when tab view is changed, put the tabid as the current tab
521
- // chrome.tabs.onActivated.addListener((info) => {
522
- // // get info about tab information from tabId
523
- // chrome.tabs.get(info.tabId, (tab) => {
524
- // // never set a reactime instance to the active tab
525
- // if (!tab.pendingUrl?.match('^chrome-extension')) {
526
- // activeTab = tab;
527
- // console.log('background tabs.onActivated has fired. activeTab: ', JSON.stringify(activeTab));
528
- // console.log(
529
- // 'background tabs.onActivated will send changeTab message to frontend if portsArr is > 0: ',
530
- // Object.keys(portsArr),
531
- // );
532
- // if (portsArr.length > 0) {
533
- // portsArr.forEach((bg) =>
534
- // bg.postMessage({
535
- // action: 'changeTab',
536
- // payload: { tabId: tab.id, title: tab.title },
537
- // }),
538
- // );
539
- // }
540
- // }
541
- // });
542
- // });
521
+ chrome . tabs . onActivated . addListener ( ( info ) => {
522
+ // get info about tab information from tabId
523
+ chrome . tabs . get ( info . tabId , ( tab ) => {
524
+ // never set a reactime instance to the active tab
525
+ if ( ! tab . pendingUrl ?. match ( '^chrome-extension' ) ) {
526
+ activeTab = tab ;
527
+ console . log ( 'background tabs.onActivated has fired. activeTab: ' , JSON . stringify ( activeTab ) ) ;
528
+ console . log (
529
+ 'background tabs.onActivated will send changeTab message to frontend if portsArr is > 0: ' ,
530
+ Object . keys ( portsArr ) ,
531
+ ) ;
532
+ if ( portsArr . length > 0 ) {
533
+ portsArr . forEach ( ( bg ) =>
534
+ bg . postMessage ( {
535
+ action : 'changeTab' ,
536
+ payload : { tabId : tab . id , title : tab . title } ,
537
+ } ) ,
538
+ ) ;
539
+ }
540
+ }
541
+ } ) ;
542
+ } ) ;
543
543
544
544
// when reactime is installed
545
545
// create a context menu that will open our devtools in a new window
@@ -584,46 +584,47 @@ chrome.contextMenus.onClicked.addListener(({ menuItemId }) => {
584
584
if ( menuItemId === 'reactime' ) chrome . windows . create ( options ) ;
585
585
} ) ;
586
586
//JR 12.20.23
587
- chrome . tabs . query ( { active : true , currentWindow : true } , ( tabs ) => {
588
- console . log ( 'onContext click tab info' , tabs , new Date ( ) . toLocaleString ( ) ) ;
589
- if ( tabs . length ) {
590
- const invokedTab = tabs [ 0 ] ;
591
- const invokedTabId = invokedTab . id ;
592
- const invokedTabTitle = invokedTab . title ;
593
- tabsObj [ invokedTabId ] = createTabObj ( invokedTabTitle ) ;
594
- console . log ( 'onContextClick tabsObj created ' , tabsObj ) ;
595
- activeTab = invokedTab ;
596
-
597
- // inject backend script
598
- const injectScript = ( file , tab ) => {
599
- const htmlBody = document . getElementsByTagName ( 'body' ) [ 0 ] ;
600
- const script = document . createElement ( 'script' ) ;
601
- script . setAttribute ( 'id' , 'reactime-backend-script' ) ;
602
- script . setAttribute ( 'type' , 'text/javascript' ) ;
603
- script . setAttribute ( 'src' , file ) ;
604
- // eslint-disable-next-line prefer-template
605
- htmlBody . appendChild ( script ) ;
606
- } ;
607
-
608
- console . log ( 'background is injecting the backend script' , new Date ( ) . toLocaleString ( ) ) ;
609
- chrome . scripting . executeScript ( {
610
- target : { tabId : invokedTabId } ,
611
- func : injectScript ,
612
- args : [ chrome . runtime . getURL ( 'bundles/backend.bundle.js' ) , invokedTabId ] ,
613
- } ) ;
587
+ //JR 1.8.23: this code fixes the no target error (still gets stuck on reactdevtools installed check), but creates an error where the addNewSnapshots reducer has an error.
588
+ // chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
589
+ // console.log('onContext click tab info', tabs, new Date().toLocaleString());
590
+ // if (tabs.length) {
591
+ // const invokedTab = tabs[0];
592
+ // const invokedTabId = invokedTab.id;
593
+ // const invokedTabTitle = invokedTab.title;
594
+ // tabsObj[invokedTabId] = createTabObj(invokedTabTitle);
595
+ // console.log('onContextClick tabsObj created ', tabsObj);
596
+ // activeTab = invokedTab;
597
+
598
+ // inject backend script
599
+ // const injectScript = (file, tab) => {
600
+ // const htmlBody = document.getElementsByTagName('body')[0];
601
+ // const script = document.createElement('script');
602
+ // script.setAttribute('id', 'reactime-backend-script');
603
+ // script.setAttribute('type', 'text/javascript');
604
+ // script.setAttribute('src', file);
605
+ // // eslint-disable-next-line prefer-template
606
+ // htmlBody.appendChild(script);
607
+ // };
608
+
609
+ // console.log('background is injecting the backend script', new Date().toLocaleString());
610
+ // chrome.scripting.executeScript({
611
+ // target: { tabId: invokedTabId },
612
+ // func: injectScript,
613
+ // args: [chrome.runtime.getURL('bundles/backend.bundle.js'), invokedTabId],
614
+ // });
614
615
615
- console . log ( 'contextclick invokedTab url, ' , invokedTab . url , 'portsArr: ' , portsArr ) ;
616
- if ( ! invokedTab . url ?. match ( '^chrome-extension' ) ) {
617
- if ( portsArr . length > 0 ) {
618
- portsArr . forEach ( ( bg ) => {
619
- console . log ( 'contextClick is sending change Tab message to ' , bg ) ;
620
- bg . postMessage ( {
621
- action : 'changeTab' ,
622
- payload : { tabId : invokedTabId , title : invokedTabTitle } ,
623
- } ) ;
624
- } ) ;
625
- }
626
- }
627
- }
628
- } ) ;
616
+ // console.log('contextclick invokedTab url, ', invokedTab.url, 'portsArr: ', portsArr);
617
+ // if (!invokedTab.url?.match('^chrome-extension')) {
618
+ // if (portsArr.length > 0) {
619
+ // portsArr.forEach((bg) => {
620
+ // console.log('contextClick is sending change Tab message to ', bg);
621
+ // bg.postMessage({
622
+ // action: 'changeTab',
623
+ // payload: { tabId: invokedTabId, title: invokedTabTitle },
624
+ // });
625
+ // });
626
+ // }
627
+ // }
628
+ // }
629
+ // });
629
630
} ) ;
0 commit comments