从内容脚本:Chrome扩展程序开发激活popup.html [英] Activate popup.html from Content Script: Chrome Extension Development
问题描述
我当前的项目需要从内容脚本打开/激活popup.html(browserAction)吗?我已经读了一些答案,说,出于安全考虑,这是不可能的.
My current project requires opening/activating popup.html (browserAction) from content script? I have read a few answers that say, it's not possible because of security concern.
例如Ans:如何打开扩展程序的用JavaScript弹出?
如果是这种情况,那么当按CTRL + D快捷键时,Chrome Bookmark Manager扩展如何执行?
If that's the case, then how Chrome Bookmark Manager extension does it when CTRL+D shortcut is pressed?
引用:书签经理扩展
推荐答案
它们只是使用命令界面,事件名称为 _execute_page_action
(或 _execute_browser_action
).他们已将默认快捷方式设置为 Ctrl + D
.
They're just using the commands interface, with an event name of _execute_page_action
(or _execute_browser_action
). They've set the default shortcut to Ctrl+D
.
激活此命令将在页面(或浏览器)操作上单击,打开弹出窗口或将操作配置为执行的任何操作.
Activating this command will perform a click on the page (or browser) action, opening the popup or whatever the action is configured to do.
Chrome仅在不与内置命令冲突的情况下使用默认快捷键,但对于指定 chrome_ui_overrides.bookmarks_ui
Chrome only respects the default shortcut key if it does not conflict with built-in commands, but it makes an exception for extensions that specify chrome_ui_overrides.bookmarks_ui
[1], which is currently restricted to the dev channel or the experimental extension by Google.
Cast扩展程序用于以编程方式打开其弹出窗口,这是我所见过的唯一窗口.该API也被列入白名单:
The Cast extension used to programmatically open its popup, which is the only one I've seen. The API is similarly whitelisted: browserAction.openPopup.
这篇关于从内容脚本:Chrome扩展程序开发激活popup.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!