1-
21const contextMenus = { }
32
43function findMenuRefItem ( theMenuArray , theMenuRef ) {
@@ -9,17 +8,6 @@ function findMenuRefItem(theMenuArray, theMenuRef) {
98 }
109}
1110
12- for ( let actionindex = 0 ; actionindex < menuActions . length ; actionindex ++ ) {
13- if ( menuActions [ actionindex ] . menu === "" ) {
14- menuActions [ actionindex ] . id = chrome . contextMenus . create ( { "title" : menuActions [ actionindex ] . title , "type" : "normal" , contexts : [ "all" ] } )
15- } else {
16- const parentId = findMenuRefItem ( menuActions , menuActions [ actionindex ] . menu )
17- menuActions [ actionindex ] . id = chrome . contextMenus . create ( { "title" : menuActions [ actionindex ] . title , "type" : "normal" , contexts : [ "all" ] , "parentId" : parentId } )
18- }
19- }
20-
21- chrome . contextMenus . onClicked . addListener ( contextMenuClickHandler )
22-
2311function contextMenuClickHandler ( info , tab ) {
2412
2513 let actionToDo
@@ -39,7 +27,7 @@ function contextMenuClickHandler(info, tab) {
3927 return
4028 }
4129
42- const errorHandler = function ( ) {
30+ function errorHandler ( ) {
4331 if ( chrome . runtime . lastError ) {
4432 console . error ( chrome . runtime . lastError . message )
4533 }
@@ -81,3 +69,14 @@ function contextMenuClickHandler(info, tab) {
8169 } )
8270 }
8371}
72+
73+ chrome . contextMenus . onClicked . addListener ( contextMenuClickHandler )
74+
75+ for ( let actionindex = 0 ; actionindex < menuActions . length ; actionindex ++ ) {
76+ if ( menuActions [ actionindex ] . menu === "" ) {
77+ menuActions [ actionindex ] . id = chrome . contextMenus . create ( { "title" : menuActions [ actionindex ] . title , "type" : "normal" , contexts : [ "all" ] } )
78+ } else {
79+ const parentId = findMenuRefItem ( menuActions , menuActions [ actionindex ] . menu )
80+ menuActions [ actionindex ] . id = chrome . contextMenus . create ( { "title" : menuActions [ actionindex ] . title , "type" : "normal" , contexts : [ "all" ] , "parentId" : parentId } )
81+ }
82+ }
0 commit comments