@@ -281,26 +281,33 @@ async function createBookmarkFromContextMenu(tab) {
281
281
282
282
// LIFECYCLE METHODS //
283
283
284
- function handleInstalled ( details ) {
284
+ async function handleInstalled ( details ) {
285
285
if ( details . reason === "install" ) {
286
286
// set uninstall URL
287
287
chrome . runtime . setUninstallURL ( "https://forms.gle/6vJPx6eaMV5xuxQk9" ) ;
288
288
// todo: detect existing speed dial folder
289
289
} else if ( details . reason === 'update' ) {
290
- if ( details . previousVersion < '3.3' ) {
291
- const url = chrome . runtime . getURL ( "updated.html" ) ;
292
- chrome . tabs . create ( { url } ) ;
293
- }
290
+ if ( details . previousVersion < '3.3' ) {
291
+ const url = chrome . runtime . getURL ( "updated.html" ) ;
292
+ chrome . tabs . create ( { url } ) ;
293
+ }
294
294
// perform any migrations here...
295
295
}
296
- // create context menu
297
- chrome . contextMenus . create ( {
298
- "title" : "Add to Speed Dial" ,
299
- "contexts" : [ 'page' ] ,
300
- "documentUrlPatterns" : [ 'https://*/*' , 'http://*/*' ] ,
301
- "id" : "addToSpeedDial"
302
- } ) ;
303
296
297
+ try {
298
+ // remove existing menus to avoid issues with previous versions
299
+ await chrome . contextMenus . removeAll ( ) ;
300
+
301
+ // create context menu
302
+ chrome . contextMenus . create ( {
303
+ title : "Add to Speed Dial" ,
304
+ contexts : [ "page" ] ,
305
+ documentUrlPatterns : [ "https://*/*" , "http://*/*" ] ,
306
+ id : "addToSpeedDial" ,
307
+ } ) ;
308
+ } catch ( error ) {
309
+ console . log ( "Error managing context menus:" , error . message ) ;
310
+ }
304
311
}
305
312
306
313
0 commit comments