@@ -24,6 +24,7 @@ import { db } from '../../models/db/dexieDb';
2424import { Rapport } from '../../models/schemas/Rapport' ;
2525import { ScheduledAutomation } from '../../models/schemas/ScheduledAutomation' ;
2626import { getActivePageInfo } from '../Content/scripts/pageInfo' ;
27+ import { requestAllSitesAccess } from '../../services/manifest_permissions' ;
2728
2829/**
2930 * Initialize services when the extension is installed / activated
@@ -220,11 +221,16 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
220221chrome . runtime . onMessageExternal . addListener ( ( message , sender , sendResponse ) => {
221222 debug ( 'onMessageExternal:start' , { message, sender} ) ;
222223
224+ let hasPermission = false ;
223225 try {
224226 ( async ( ) => {
225227 switch ( message . cmd ) {
226- case 'singleCollect' : // TODO: Deprecated remove after 1/1/26
227228 case 'deepSave' :
229+ hasPermission = await requestAllSitesAccess ( )
230+ if ( ! hasPermission ) {
231+ sendResponse ( { completed : false , message : 'You must accept the permissions change in order to enable this automation.' } )
232+ break ;
233+ }
228234 await createTab ( message . url ) ;
229235 const activeTab = await getActiveTab ( ) ;
230236 // wait for page contents to load
@@ -233,36 +239,56 @@ chrome.runtime.onMessageExternal.addListener((message, sender, sendResponse) =>
233239 // TODO: make this configurable or dynamic based on the domain
234240 await capture ( activeTab , pageInfo , true ) ;
235241 sendResponse ( { completed : true } )
242+ try {
243+ await chrome . tabs . remove ( activeTab . id ) ;
244+ }
245+ catch ( error ) {
246+ // could not close the tab
247+ }
236248 break ;
237249 case AUTO_COLLECT_STARTING :
238- case 'autoscrollCollect' : // TODO: Deprecated remove after 1/1/26
250+ hasPermission = await requestAllSitesAccess ( )
251+ if ( ! hasPermission ) {
252+ sendResponse ( { completed : false , message : 'You must accept the permissions change in order to enable this automation.' } )
253+ break ;
254+ }
239255 await createTab ( message . url ) ;
240256 await sleep ( 3000 ) ;
241257 sendResponse ( { completed : true } )
242-
243258 chrome . tabs . sendMessage ( ( await getActiveTab ( ) ) . id , { cmd : ACTIVATE_CAPTURE , requestId : crypto . randomUUID ( ) } )
244259 . then ( response => {
245260 debug ( ACTIVATE_CAPTURE + ':' , response ) ;
246261 } )
247262 break ;
248263 case ENQUEUE_BULK_AUTOMATION_URL :
249264 case 'enqueueBulkAutomation' :
265+ hasPermission = await requestAllSitesAccess ( )
266+ if ( ! hasPermission ) {
267+ sendResponse ( { completed : false , message : 'You must accept the permissions change in order to enable this automation.' } )
268+ break ;
269+ }
250270 const record = await BulkAutomationUrl . createBulkAutomationJob ( message . url ) ;
251271 await db . bulkAutomation . add ( record ) ;
252272 break ;
253273 case 'ping' :
254274 sendResponse ( { completed : true } ) ;
255275 break ;
256276 case 'monitorHourly' :
277+ hasPermission = await requestAllSitesAccess ( )
278+ if ( ! hasPermission ) {
279+ sendResponse ( { completed : false , message : 'You must accept the permissions change in order to enable this automation.' } )
280+ break ;
281+ }
257282 await ScheduledAutomation . addMonitor ( message . url , '0 0 * * * *' ) ;
283+ sendResponse ( { completed : true } )
258284 break ;
259285 default :
260286 return false ;
261287 }
262288 } ) ( )
263289 return false ;
264290 } catch ( e ) {
265- debug ( 'onMessageExternal:failure' , { message, sender } )
291+ debug ( 'onMessageExternal:failure' , { message, sender, e } )
266292 }
267293} )
268294
0 commit comments