99 setLocalOption ,
1010 getSharedArchives ,
1111} from "../localstorage" ;
12+ import { isValidUrl } from "../utils" ;
1213// ===========================================================================
1314self . recorders = { } ;
1415self . newRecId = null ;
@@ -22,6 +23,7 @@ let newRecCollId = null;
2223let defaultCollId = null ;
2324let autorun = false ;
2425let isRecordingEnabled = false ;
26+ let skipDomains = [ ] as string [ ] ;
2527
2628const openWinMap = new Map ( ) ;
2729
@@ -32,6 +34,12 @@ const disabledCSPTabs = new Set();
3234// @ts -expect-error - TS7034 - Variable 'sidepanelPort' implicitly has type 'any' in some locations where its type cannot be determined.
3335let sidepanelPort = null ;
3436
37+ ( async function loadSkipDomains ( ) {
38+ // @ts -expect-error
39+ skipDomains = ( await getLocalOption ( "skipDomains" ) ) || [ ] ;
40+ console . log ( "bg.skipDomains:" , skipDomains ) ;
41+ } ) ( ) ;
42+
3543// ===========================================================================
3644
3745function main ( ) {
@@ -136,7 +144,7 @@ function sidepanelHandler(port) {
136144 //@ts -expect-error tabs has any type
137145 async ( tabs ) => {
138146 for ( const tab of tabs ) {
139- if ( ! isValidUrl ( tab . url ) ) continue ;
147+ if ( ! isValidUrl ( tab . url , skipDomains ) ) continue ;
140148
141149 await startRecorder (
142150 tab . id ,
@@ -217,6 +225,13 @@ chrome.runtime.onMessage.addListener(
217225 ( message /*sender, sendResponse*/ ) => {
218226 console . log ( "onMessage" , message ) ;
219227 switch ( message . msg ) {
228+ case "optionsChanged" :
229+ for ( const rec of Object . values ( self . recorders ) ) {
230+ rec . initOpts ( ) ;
231+ rec . doUpdateStatus ( ) ;
232+ }
233+ break ;
234+
220235 case "startNew" :
221236 ( async ( ) => {
222237 newRecUrl = message . url ;
@@ -256,7 +271,7 @@ chrome.tabs.onActivated.addListener(async ({ tabId }) => {
256271 chrome . tabs . get ( tabId , resolve ) ,
257272 ) ;
258273
259- if ( ! isValidUrl ( tab . url ) ) return ;
274+ if ( ! isValidUrl ( tab . url , skipDomains ) ) return ;
260275 if ( ! self . recorders [ tabId ] ) {
261276 await startRecorder (
262277 tabId ,
@@ -296,7 +311,7 @@ chrome.tabs.onCreated.addListener((tab) => {
296311 newRecCollId = null ;
297312 } else if (
298313 tab . openerTabId &&
299- ( ! tab . pendingUrl || isValidUrl ( tab . pendingUrl ) ) &&
314+ ( ! tab . pendingUrl || isValidUrl ( tab . pendingUrl , skipDomains ) ) &&
300315 // @ts -expect-error - TS2339 - Property 'running' does not exist on type 'BrowserRecorder'.
301316 self . recorders [ tab . openerTabId ] ?. running
302317 ) {
@@ -311,7 +326,7 @@ chrome.tabs.onCreated.addListener((tab) => {
311326 }
312327
313328 if ( start ) {
314- if ( openUrl && ! isValidUrl ( openUrl ) ) {
329+ if ( openUrl && ! isValidUrl ( openUrl , skipDomains ) ) {
315330 return ;
316331 }
317332 startRecorder (
@@ -339,7 +354,7 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo) => {
339354
340355 // @ts -expect-error - TS2339 - Property 'waitForTabUpdate' does not exist on type 'BrowserRecorder'.
341356 if ( recorder . waitForTabUpdate ) {
342- if ( isValidUrl ( changeInfo . url ) ) {
357+ if ( isValidUrl ( changeInfo . url , skipDomains ) ) {
343358 recorder . attach ( ) ;
344359 } else {
345360 // @ts -expect-error - TS2339 - Property 'waitForTabUpdate' does not exist on type 'BrowserRecorder'.
@@ -351,7 +366,7 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo) => {
351366 } else if ( changeInfo . url ) {
352367 if (
353368 isRecordingEnabled &&
354- isValidUrl ( changeInfo . url ) &&
369+ isValidUrl ( changeInfo . url , skipDomains ) &&
355370 ! self . recorders [ tabId ]
356371 ) {
357372 // @ts -expect-error - TS2554 - Expected 2 arguments, but got 3.
@@ -361,7 +376,7 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo) => {
361376 if ( openWinMap . has ( changeInfo . url ) ) {
362377 const collId = openWinMap . get ( changeInfo . url ) ;
363378 openWinMap . delete ( changeInfo . url ) ;
364- if ( ! tabId || ! isValidUrl ( changeInfo . url ) ) return ;
379+ if ( ! tabId || ! isValidUrl ( changeInfo . url , skipDomains ) ) return ;
365380
366381 // @ts -expect-error - TS2554 - Expected 2 arguments, but got 3.
367382 startRecorder ( tabId , { collId, autorun } , changeInfo . url ) ;
@@ -386,7 +401,7 @@ chrome.contextMenus.onClicked.addListener((info, tab) => {
386401
387402 case "toggle-rec" :
388403 if ( ! isRecording ( tab . id ) ) {
389- if ( isValidUrl ( tab . url ) ) {
404+ if ( isValidUrl ( tab . url , skipDomains ) ) {
390405 // @ts -expect-error - TS2554 - Expected 2 arguments, but got 1.
391406 startRecorder ( tab . id ) ;
392407 }
@@ -457,17 +472,6 @@ function isRecording(tabId) {
457472 return self . recorders [ tabId ] ?. running ;
458473}
459474
460- // ===========================================================================
461- // @ts -expect-error - TS7006 - Parameter 'url' implicitly has an 'any' type.
462- function isValidUrl ( url ) {
463- return (
464- url &&
465- ( url === "about:blank" ||
466- url . startsWith ( "https:" ) ||
467- url . startsWith ( "http:" ) )
468- ) ;
469- }
470-
471475// ===========================================================================
472476// @ts -expect-error - TS7006 - Parameter 'tabId' implicitly has an 'any' type.
473477async function disableCSPForTab ( tabId ) {
0 commit comments