【发布时间】:2020-11-22 23:55:20
【问题描述】:
我想制作一个 chrome 扩展,我可以在特定页面上使用键盘命令(例如:“Ctrl+Shift+A”),然后触发一些 DOM 操作代码(例如单击按钮)。
但我面临的问题是“chrome.commands”在后台环境中运行(manifest.json 中的背景属性),如果我在 content_scripts 中包含“chrome.commands.onCommand”(在 manifest.json 中)我得到这个错误。
Uncaught TypeError: Cannot read property 'onCommand' of undefined.
如何让它发挥作用?
【问题讨论】:
标签: javascript dom google-chrome-extension