-
Notifications
You must be signed in to change notification settings - Fork 4
Description
The Safari app extension contextual menu items API is dynamic, flexible, open-ended:
The extension content script can respond to any DOM "contextmenu" event, perform any desired processing, and pass along any arbitrary data in the safari.extension.setContextMenuEventUserInfo() call. . In the SFSafariExtensionHandler, the extension can use validateContextMenuItemWithCommand: to show or hide any contextual menu items and set the names of the menu items to fit the context.
Unfortunately, the Chrome extension contextMenus API, which is used by Safari web extensions, is very static, inflexible, limit. The properties of the contextual menu items have to be predetermined in the create() or update() calls, including specifying the enabled state, the menu title, and the documentUrlPatterns in advance. Moreover, the OnClickData is extremely very limited and isn't even triggered by every "contextmenu" event.
It would be extremely difficult to port my Safari app extension (Apple ID 6471380298 in the App Store) to the Safari web extension API with only the latter's contextMenus API. I would lose a number of features. It would be a major downgrade.
The Firefox-specific extension menus API has more flexibility, with onShown, refresh, and getTargetElement, so adding those features would be an improvement, but it's still significantly worse than the existing Safari app extension API.
I'm not suggesting that the contextMenus API be removed from Safari web extensions. Obviously it's necessary for cross-browser compatibility. I'm merely requesting that the Safari app extension API be added as an nice option to Safari web extensions.