Chrome扩展如何配置才能在chrome://extensions/shortcuts页显示激活快捷键选项
你需要在manifest.json中新增commands配置项,使用Chrome内置的保留命令即可实现需求,无需额外编写功能代码。
Manifest V3 配置示例(当前Chrome官方主推版本,推荐使用)
{ "manifest_version": 3, "name": "你的扩展名称", "version": "1.0", "action": { "default_popup": "popup.html" }, // 新增快捷键相关配置 "commands": { "_execute_action": { "suggested_key": { "default": "Ctrl+Shift+Y", "mac": "Command+Shift+Y" }, "description": "激活扩展弹窗" } } }
字段说明
_execute_action是Chrome内置的保留命令,触发后会自动打开你在action.default_popup中指定的popup.html页面,不需要额外写监听逻辑suggested_key为可选字段,是你预设的默认快捷键,用户可以后续在chrome://extensions/shortcuts页面自行修改description为快捷键的功能说明,会显示在快捷键设置页面对应的扩展条目中
如果你仍在使用Manifest V2(已被Chrome官方停止支持,不推荐)
将内置命令替换为_execute_browser_action(对应browser_action配置的扩展)或者_execute_page_action(对应page_action配置的扩展)即可。
配置完成后在扩展管理页面重新加载你的扩展,刷新chrome://extensions/shortcuts页面就能看到你的扩展出现在列表中。
内容的提问来源于stack exchange,提问作者th1rdey3
相关产品推荐
相关产品推荐

