File tree Expand file tree Collapse file tree 2 files changed +5
-13
lines changed Expand file tree Collapse file tree 2 files changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -85,8 +85,7 @@ export function refreshMenu() {
8585 }
8686
8787 // Add custom selection tools that are active
88- for ( let i = 0 ; i < userConfig . customSelectionTools . length ; i ++ ) {
89- const tool = userConfig . customSelectionTools [ i ]
88+ userConfig . customSelectionTools . forEach ( ( tool , i ) => {
9089 if ( tool . active && tool . name ) {
9190 Browser . contextMenus . create ( {
9291 id : menuId + 'custom_' + i ,
@@ -95,7 +94,7 @@ export function refreshMenu() {
9594 contexts : [ 'selection' ] ,
9695 } )
9796 }
98- }
97+ } )
9998
10099 Browser . contextMenus . onClicked . addListener ( onClickMenu )
101100 } )
Original file line number Diff line number Diff line change @@ -291,16 +291,9 @@ async function prepareForRightClickMenu() {
291291 } else if ( data . itemId . startsWith ( 'custom_' ) ) {
292292 // Handle custom selection tools from context menu
293293 const customIndex = parseInt ( data . itemId . replace ( 'custom_' , '' ) , 10 )
294- if (
295- ! isNaN ( customIndex ) &&
296- customIndex >= 0 &&
297- userConfig . customSelectionTools &&
298- customIndex < userConfig . customSelectionTools . length
299- ) {
300- const customTool = userConfig . customSelectionTools [ customIndex ]
301- if ( customTool . active && customTool . name ) {
302- prompt = customTool . prompt . replace ( '{{selection}}' , data . selectionText )
303- }
294+ const customTool = userConfig . customSelectionTools ?. [ customIndex ]
295+ if ( customTool ?. active && customTool ?. name ) {
296+ prompt = customTool . prompt . replace ( '{{selection}}' , data . selectionText )
304297 }
305298 } else if ( data . itemId in menuConfig ) {
306299 const menuItem = menuConfig [ data . itemId ]
You can’t perform that action at this time.
0 commit comments