File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed
Expand file tree Collapse file tree 3 files changed +44
-1
lines changed File renamed without changes.
Original file line number Diff line number Diff line change 1+ // import 'core-js';
2+ // const reactimeBackend = require('../../dev-reactime/index.js');
3+
4+ let firstMessage : boolean = true ;
5+
6+ // listening for messages from npm package
7+ window . addEventListener ( 'message' , msg => { // runs automatically every second
8+ // window listener picks up the message it sends, so we should filter
9+ // messages sent by contentscrip
10+ if ( firstMessage ) {
11+ // tell the background script that the tab has reloaded
12+ chrome . runtime . sendMessage ( { action : 'tabReload' } ) ;
13+ firstMessage = false ;
14+ }
15+
16+ // post initial Message to background.js
17+ const { action } : { action : string } = msg . data ;
18+
19+ if ( action === 'recordSnap' ) { // this is firing on page load
20+ chrome . runtime . sendMessage ( msg . data ) ;
21+ }
22+ } ) ;
23+
24+ // listening for messages from the UI
25+ chrome . runtime . onMessage . addListener ( request => { // seems to never fire
26+ // send the message to npm package
27+ const { action } : { action : string } = request ;
28+ switch ( action ) {
29+ case 'jumpToSnap' :
30+ chrome . runtime . sendMessage ( request ) ;
31+ window . postMessage ( request , '*' ) ;
32+ break ;
33+ case 'setLock' :
34+ case 'setPause' :
35+ window . postMessage ( request , '*' ) ;
36+ break ;
37+ default :
38+ break ;
39+ }
40+ return true ; // attempt to fix port closing console error
41+ } ) ;
42+
43+ chrome . runtime . sendMessage ( { action : 'injectScript' } ) ;
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ const config = {
88 // app: './src/app/index.js',
99 app : './src/app/index.tsx' ,
1010 background : './src/extension/background.js' ,
11- content : './src/extension/contentScript.js ' ,
11+ content : './src/extension/contentScript.ts ' ,
1212 backend : './src/backend/index.ts' ,
1313 } ,
1414 output : {
You can’t perform that action at this time.
0 commit comments