1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[
{
"namespace": "manifest",
"types": [
{
"$extend": "PermissionNoPrompt",
"choices": [
{
"type": "string",
"enum": ["menus", "contextMenus"]
}
]
},
{
"$extend": "OptionalPermissionNoPrompt",
"choices": [
{
"type": "string",
"enum": ["menus.overrideContext"]
}
]
}
]
},
{
"namespace": "contextMenus",
"permissions": ["contextMenus"],
"description": "Use the browser.contextMenus API to add items to the browser's context menu. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages.",
"$import": "menus"
},
{
"namespace": "menus",
"permissions": ["menus"],
"description": "Use the browser.menus API to add items to the browser's menus. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages.",
"properties": {
"ACTION_MENU_TOP_LEVEL_LIMIT": {
"value": 6,
"description": "The maximum number of top level extension items that can be added to an extension action context menu. Any items beyond this limit will be ignored."
}
},
"types": [
{
"id": "ContextType",
"description": "The different contexts a menu can appear in. Specifying 'all' is equivalent to the combination of all other contexts except for 'tab' and 'tools_menu'.",
"choices": [
{
"type": "string",
"enum": [
"all",
"page",
"frame",
"selection",
"link",
"editable",
"password",
"image",
"video",
"audio",
"launcher",
"bookmark",
"tab",
"tools_menu"
]
},
{
"type": "string",
"enum": ["browser_action", "page_action"],
"max_manifest_version": 2
},
{
"type": "string",
"enum": ["action"],
"min_manifest_version": 3
}
]
},
{
"id": "ItemType",
"type": "string",
"enum": ["normal", "checkbox", "radio", "separator"],
"description": "The type of menu item."
},
{
"id": "OnClickData",
"type": "object",
"description": "Information sent when a context menu item is clicked.",
"properties": {
"menuItemId": {
"choices": [{ "type": "integer" }, { "type": "string" }],
"description": "The ID of the menu item that was clicked."
},
"parentMenuItemId": {
"choices": [{ "type": "integer" }, { "type": "string" }],
"optional": true,
"description": "The parent ID, if any, for the item clicked."
},
"viewType": {
"$ref": "extension.ViewType",
"optional": true,
"description": "The type of view where the menu is clicked. May be unset if the menu is not associated with a view."
},
"mediaType": {
"type": "string",
"optional": true,
"description": "One of 'image', 'video', or 'audio' if the context menu was activated on one of these types of elements."
},
"linkText": {
"type": "string",
"optional": true,
"description": "If the element is a link, the text of that link."
},
"linkUrl": {
"type": "string",
"optional": true,
"description": "If the element is a link, the URL it points to."
},
"srcUrl": {
"type": "string",
"optional": true,
"description": "Will be present for elements with a 'src' URL."
},
"pageUrl": {
"type": "string",
"optional": true,
"description": "The URL of the page where the menu item was clicked. This property is not set if the click occured in a context where there is no current page, such as in a launcher context menu."
},
"frameId": {
"type": "integer",
"optional": true,
"minimum": 0,
"description": "The id of the frame of the element where the context menu was clicked."
},
"frameUrl": {
"type": "string",
"optional": true,
"description": " The URL of the frame of the element where the context menu was clicked, if it was in a frame."
},
"selectionText": {
"type": "string",
"optional": true,
"description": "The text for the context selection, if any."
},
"editable": {
"type": "boolean",
"description": "A flag indicating whether the element is editable (text input, textarea, etc.)."
},
"wasChecked": {
"type": "boolean",
"optional": true,
"description": "A flag indicating the state of a checkbox or radio item before it was clicked."
},
"checked": {
"type": "boolean",
"optional": true,
"description": "A flag indicating the state of a checkbox or radio item after it is clicked."
},
"bookmarkId": {
"type": "string",
"optional": true,
"description": "The id of the bookmark where the context menu was clicked, if it was on a bookmark."
},
"modifiers": {
"type": "array",
"items": {
"type": "string",
"enum": ["Shift", "Alt", "Command", "Ctrl", "MacCtrl"]
},
"description": "An array of keyboard modifiers that were held while the menu item was clicked."
},
"button": {
"type": "integer",
"optional": true,
"description": "An integer value of button by which menu item was clicked."
},
"targetElementId": {
"type": "integer",
"optional": true,
"description": "An identifier of the clicked element, if any. Use menus.getTargetElement in the page to find the corresponding element."
}
}
}
],
"functions": [
{
"name": "create",
"type": "function",
"description": "Creates a new context menu item. Note that if an error occurs during creation, you may not find out until the creation callback fires (the details will be in $(ref:runtime.lastError)).",
"returns": {
"choices": [{ "type": "integer" }, { "type": "string" }],
"description": "The ID of the newly created item."
},
"parameters": [
{
"type": "object",
"name": "createProperties",
"properties": {
"type": {
"$ref": "ItemType",
"optional": true,
"description": "The type of menu item. Defaults to 'normal' if not specified."
},
"id": {
"type": "string",
"optional": true,
"description": "The unique ID to assign to this item. Mandatory for event pages. Cannot be the same as another ID for this extension."
},
"icons": {
"type": "object",
"optional": true,
"patternProperties": {
"^[1-9]\\d*$": { "type": "string" }
}
},
"title": {
"type": "string",
"optional": true,
"description": "The text to be displayed in the item; this is <em>required</em> unless <code>type</code> is 'separator'. When the context is 'selection', you can use <code>%s</code> within the string to show the selected text. For example, if this parameter's value is \"Translate '%s' to Pig Latin\" and the user selects the word \"cool\", the context menu item for the selection is \"Translate 'cool' to Pig Latin\"."
},
"checked": {
"type": "boolean",
"optional": true,
"description": "The initial state of a checkbox or radio item: true for selected and false for unselected. Only one radio item can be selected at a time in a given group of radio items."
},
"contexts": {
"type": "array",
"items": {
"$ref": "ContextType"
},
"minItems": 1,
"optional": true,
"description": "List of contexts this menu item will appear in. Defaults to ['page'] if not specified."
},
"viewTypes": {
"type": "array",
"items": {
"$ref": "extension.ViewType"
},
"minItems": 1,
"optional": true,
"description": "List of view types where the menu item will be shown. Defaults to any view, including those without a viewType."
},
"visible": {
"type": "boolean",
"optional": true,
"description": "Whether the item is visible in the menu."
},
"onclick": {
"type": "function",
"max_manifest_version": 2,
"optional": true,
"description": "A function that will be called back when the menu item is clicked. Event pages cannot use this; instead, they should register a listener for $(ref:contextMenus.onClicked).",
"parameters": [
{
"name": "info",
"$ref": "OnClickData",
"description": "Information about the item clicked and the context where the click happened."
},
{
"name": "tab",
"$ref": "tabs.Tab",
"description": "The details of the tab where the click took place. Note: this parameter only present for extensions."
}
]
},
"parentId": {
"choices": [{ "type": "integer" }, { "type": "string" }],
"optional": true,
"description": "The ID of a parent menu item; this makes the item a child of a previously added item."
},
"documentUrlPatterns": {
"type": "array",
"items": { "type": "string" },
"optional": true,
"description": "Lets you restrict the item to apply only to documents whose URL matches one of the given patterns. (This applies to frames as well.) For details on the format of a pattern, see $(topic:match_patterns)[Match Patterns]."
},
"targetUrlPatterns": {
"type": "array",
"items": { "type": "string" },
"optional": true,
"description": "Similar to documentUrlPatterns, but lets you filter based on the src attribute of img/audio/video tags and the href of anchor tags."
},
"enabled": {
"type": "boolean",
"optional": true,
"description": "Whether this context menu item is enabled or disabled. Defaults to true."
},
"command": {
"choices": [
{ "type": "string" },
{
"type": "string",
"enum": [
"_execute_browser_action",
"_execute_page_action",
"_execute_sidebar_action"
],
"max_manifest_version": 2,
"description": "Manifest V2 supports internal commands _execute_page_action, _execute_browser_action and _execute_sidebar_action."
},
{
"type": "string",
"enum": [
"_execute_action",
"_execute_page_action",
"_execute_sidebar_action"
],
"min_manifest_version": 3,
"description": "Manifest V3 supports internal commands _execute_page_action, _execute_action and _execute_sidebar_action."
}
],
"optional": true,
"description": "Specifies a command to issue for the context click."
}
}
},
{
"type": "function",
"name": "callback",
"optional": true,
"description": "Called when the item has been created in the browser. If there were any problems creating the item, details will be available in $(ref:runtime.lastError).",
"parameters": []
}
]
},
{
"name": "update",
"type": "function",
"description": "Updates a previously created context menu item.",
"async": "callback",
"parameters": [
{
"choices": [{ "type": "integer" }, { "type": "string" }],
"name": "id",
"description": "The ID of the item to update."
},
{
"type": "object",
"name": "updateProperties",
"description": "The properties to update. Accepts the same values as the create function.",
"properties": {
"type": {
"$ref": "ItemType",
"optional": true
},
"icons": {
"type": "object",
"optional": "omit-key-if-missing",
"patternProperties": {
"^[1-9]\\d*$": { "type": "string" }
}
},
"title": {
"type": "string",
"optional": true
},
"checked": {
"type": "boolean",
"optional": true
},
"contexts": {
"type": "array",
"items": {
"$ref": "ContextType"
},
"minItems": 1,
"optional": true
},
"viewTypes": {
"type": "array",
"items": {
"$ref": "extension.ViewType"
},
"minItems": 1,
"optional": true
},
"visible": {
"type": "boolean",
"optional": true,
"description": "Whether the item is visible in the menu."
},
"onclick": {
"type": "function",
"max_manifest_version": 2,
"optional": "omit-key-if-missing",
"parameters": [
{
"name": "info",
"$ref": "OnClickData"
},
{
"name": "tab",
"$ref": "tabs.Tab",
"description": "The details of the tab where the click took place. Note: this parameter only present for extensions."
}
]
},
"parentId": {
"choices": [{ "type": "integer" }, { "type": "string" }],
"optional": true,
"description": "Note: You cannot change an item to be a child of one of its own descendants."
},
"documentUrlPatterns": {
"type": "array",
"items": { "type": "string" },
"optional": true
},
"targetUrlPatterns": {
"type": "array",
"items": { "type": "string" },
"optional": true
},
"enabled": {
"type": "boolean",
"optional": true
}
}
},
{
"type": "function",
"name": "callback",
"optional": true,
"parameters": [],
"description": "Called when the context menu has been updated."
}
]
},
{
"name": "remove",
"type": "function",
"description": "Removes a context menu item.",
"async": "callback",
"parameters": [
{
"choices": [{ "type": "integer" }, { "type": "string" }],
"name": "menuItemId",
"description": "The ID of the context menu item to remove."
},
{
"type": "function",
"name": "callback",
"optional": true,
"parameters": [],
"description": "Called when the context menu has been removed."
}
]
},
{
"name": "removeAll",
"type": "function",
"description": "Removes all context menu items added by this extension.",
"async": "callback",
"parameters": [
{
"type": "function",
"name": "callback",
"optional": true,
"parameters": [],
"description": "Called when removal is complete."
}
]
},
{
"name": "overrideContext",
"permissions": ["menus.overrideContext"],
"type": "function",
"description": "Show the matching menu items from this extension instead of the default menu. This should be called during a 'contextmenu' DOM event handler, and only applies to the menu that opens after this event.",
"parameters": [
{
"name": "contextOptions",
"type": "object",
"properties": {
"showDefaults": {
"type": "boolean",
"optional": true,
"default": false,
"description": "Whether to also include default menu items in the menu."
},
"context": {
"type": "string",
"enum": ["bookmark", "tab"],
"optional": true,
"description": "ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark' and 'tab' are supported. showDefaults cannot be used with this option."
},
"bookmarkId": {
"type": "string",
"minLength": 1,
"optional": true,
"description": "Required when context is 'bookmark'. Requires 'bookmark' permission."
},
"tabId": {
"type": "integer",
"minimum": 0,
"optional": true,
"description": "Required when context is 'tab'. Requires 'tabs' permission."
}
}
}
]
},
{
"name": "refresh",
"type": "function",
"description": "Updates the extension items in the shown menu, including changes that have been made since the menu was shown. Has no effect if the menu is hidden. Rebuilding a shown menu is an expensive operation, only invoke this method when necessary.",
"async": true,
"parameters": []
}
],
"events": [
{
"name": "onClicked",
"type": "function",
"description": "Fired when a context menu item is clicked.",
"parameters": [
{
"name": "info",
"$ref": "OnClickData",
"description": "Information about the item clicked and the context where the click happened."
},
{
"name": "tab",
"$ref": "tabs.Tab",
"description": "The details of the tab where the click took place. If the click did not take place in a tab, this parameter will be missing.",
"optional": true
}
]
},
{
"name": "onShown",
"type": "function",
"description": "Fired when a menu is shown. The extension can add, modify or remove menu items and call menus.refresh() to update the menu.",
"parameters": [
{
"name": "info",
"type": "object",
"description": "Information about the context of the menu action and the created menu items. For more information about each property, see OnClickData. The following properties are only set if the extension has host permissions for the given context: linkUrl, linkText, srcUrl, pageUrl, frameUrl, selectionText.",
"properties": {
"menuIds": {
"description": "A list of IDs of the menu items that were shown.",
"type": "array",
"items": {
"choices": [{ "type": "integer" }, { "type": "string" }]
}
},
"contexts": {
"description": "A list of all contexts that apply to the menu.",
"type": "array",
"items": { "$ref": "ContextType" }
},
"viewType": {
"$ref": "extension.ViewType",
"optional": true
},
"editable": {
"type": "boolean"
},
"mediaType": {
"type": "string",
"optional": true
},
"linkUrl": {
"type": "string",
"optional": true
},
"linkText": {
"type": "string",
"optional": true
},
"srcUrl": {
"type": "string",
"optional": true
},
"pageUrl": {
"type": "string",
"optional": true
},
"frameUrl": {
"type": "string",
"optional": true
},
"selectionText": {
"type": "string",
"optional": true
},
"targetElementId": {
"type": "integer",
"optional": true
}
}
},
{
"name": "tab",
"$ref": "tabs.Tab",
"description": "The details of the tab where the menu was opened."
}
]
},
{
"name": "onHidden",
"type": "function",
"description": "Fired when a menu is hidden. This event is only fired if onShown has fired before.",
"parameters": []
}
]
}
]
|