@@ -162,15 +162,23 @@ chrome.runtime.onConnect.addListener((port) => {
162
162
163
163
Again, this port object is used for communication within your extension, not for communication with external ports or tabs in the Chrome browser. If you need to interact with specific tabs or external ports, you would use other APIs or methods, such as chrome.tabs or other Chrome Extension APIs.
164
164
*/
165
- console . log ( 'tabsObj onConnect: ' , JSON . stringify ( tabsObj ) ) ;
165
+ console . log (
166
+ 'tabsObj onConnect: ' ,
167
+ JSON . stringify ( tabsObj [ 0 ] ?. status ) ,
168
+ 'time: ' ,
169
+ new Date ( ) . toLocaleString ( ) ,
170
+ ) ;
166
171
portsArr . push ( port ) ; // push each Reactime communication channel object to the portsArr
167
172
console . log ( 'portsArr onConnect: ' , Object . keys ( portsArr ) ) ;
168
173
169
- // JR: CONSIDER DELETING
174
+ // JR: CONSIDER DELETING?
170
175
// 12.20.23 commenting out, possible culprit of many in no target bug
171
176
if ( portsArr . length > 0 ) {
172
177
portsArr . forEach ( ( bg , index ) => {
173
- console . log ( 'background onConnect. Send changeTab for port ' , index ) ;
178
+ console . log (
179
+ 'background onConnect is sending a changeTab message to frontend for port ' ,
180
+ index ,
181
+ ) ;
174
182
// go through each port object (each Reactime instance)
175
183
bg . postMessage ( {
176
184
// send passed in action object as a message to the current port
@@ -180,12 +188,16 @@ chrome.runtime.onConnect.addListener((port) => {
180
188
} ) ;
181
189
}
182
190
183
- // JR: CONSIDER DELETING
191
+ // JR: CONSIDER DELETING?
184
192
if ( Object . keys ( tabsObj ) . length > 0 ) {
185
- port . postMessage ( {
186
- action : 'initialConnectSnapshots' ,
187
- payload : tabsObj ,
188
- } ) ;
193
+ console . log (
194
+ 'background onConnect is sending a initialConnectSnapshots message to frontend. Time: ' ,
195
+ new Date ( ) . toLocaleString ( ) ,
196
+ ) ,
197
+ port . postMessage ( {
198
+ action : 'initialConnectSnapshots' ,
199
+ payload : tabsObj ,
200
+ } ) ;
189
201
}
190
202
191
203
// every time devtool is closed, remove the port from portsArr
@@ -277,7 +289,16 @@ chrome.runtime.onConnect.addListener((port) => {
277
289
// INCOMING MESSAGE FROM CONTENT SCRIPT TO BACKGROUND.JS
278
290
// background.js listening for a message from contentScript.js
279
291
chrome . runtime . onMessage . addListener ( ( request , sender , sendResponse ) => {
280
- console . log ( 'background.js received message with action: ' , request . action , request ) ;
292
+ console . log (
293
+ 'background.js received message from content script with type: ' ,
294
+ request . type ,
295
+ 'action: ' ,
296
+ request . action ,
297
+ 'request body: ' ,
298
+ request ,
299
+ 'time: ' ,
300
+ new Date ( ) . toLocaleString ( ) ,
301
+ ) ;
281
302
// AUTOMATIC MESSAGE SENT BY CHROME WHEN CONTENT SCRIPT IS FIRST LOADED: set Content
282
303
if ( request . type === 'SIGN_CONNECT' ) {
283
304
return true ;
@@ -307,7 +328,13 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
307
328
// everytime we get a new tabId, add it to the object
308
329
if ( isReactTimeTravel && ! ( tabId in tabsObj ) ) {
309
330
tabsObj [ tabId ] = createTabObj ( tabTitle ) ;
310
- console . log ( 'tabsObj after createTabObj function call: ' , tabsObj ) ;
331
+
332
+ console . log (
333
+ 'tabsObj after createTabObj function call: ' ,
334
+ JSON . stringify ( tabsObj [ 0 ] ?. status ) ,
335
+ 'time: ' ,
336
+ new Date ( ) . toLocaleString ( ) ,
337
+ ) ;
311
338
}
312
339
313
340
switch ( action ) {
@@ -375,6 +402,11 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
375
402
function : injectScript ,
376
403
args : [ chrome . runtime . getURL ( 'bundles/backend.bundle.js' ) , tabId ] ,
377
404
} ) ;
405
+
406
+ console . log (
407
+ 'background injected the backend bundle into the webpage. Time: ' ,
408
+ new Date ( ) . toLocaleString ( ) ,
409
+ ) ;
378
410
break ;
379
411
}
380
412
case 'recordSnap' : {
@@ -486,9 +518,11 @@ chrome.tabs.onActivated.addListener((info) => {
486
518
// never set a reactime instance to the active tab
487
519
if ( ! tab . pendingUrl ?. match ( '^chrome-extension' ) ) {
488
520
activeTab = tab ;
489
- console . log ( 'tabs.onActivated info: ' , info ) ;
490
- console . log ( 'activeTab: ' , activeTab ) ;
491
- console . log ( 'tabs.onActivated portsArr: ' , portsArr ) ;
521
+ console . log ( 'background tabs.onActivated has fired. activeTab: ' , JSON . stringify ( activeTab ) ) ;
522
+ console . log (
523
+ 'background tabs.onActivated will send changeTab message to frontend if portsArr is > 0: ' ,
524
+ Object . keys ( portsArr ) ,
525
+ ) ;
492
526
if ( portsArr . length > 0 ) {
493
527
portsArr . forEach ( ( bg ) =>
494
528
bg . postMessage ( {
0 commit comments