[英]how to set associate a hotkey to my chrome extension browser_action?
I have set up a hotkey in my manifest.json file, and a bogus listener in my background.js 我在manifest.json文件中设置了一个热键,并在background.js中设置了虚假的监听器
If i hit the hotkey combination, it works. 如果我按了热键组合,它将起作用。
Now, i'm missing how to actually do what i want it to do: launch the extension's browser_action : open the popup.html (which is a search your bookmarks input field). 现在,我不知道如何实际执行我想做的事情:启动扩展程序的browser_action:打开popup.html(这是对您的书签输入字段的搜索)。 I've been looking for a method like chrome.trigger('browserAction');
我一直在寻找像chrome.trigger('browserAction');
这样的方法chrome.trigger('browserAction');
Perhaps i'm missing something really obvious... 也许我缺少真正明显的东西...
my background.js 我的background.js
chrome.commands.onCommand.addListener(function(command) {
alert('Command:'+ command);
});
manifest.json (extract) manifest.json(解压缩)
"commands": {
"browser_action": {
"suggested_key": {
"default": "Ctrl+Shift+U",
"mac": "Alt+Shift+U"
},
"description": "Opens the extension"
}
},
"browser_action": {
"default_title": "YURLS",
"default_icon": "icon16.png",
"default_popup": "popup.html"
},
ah. 啊。 Simply changing the command name to the magic word _execute_browser_action
in the manifest.json file did the trick. 只需将清单名称更改为manifest.json文件中的魔术词_execute_browser_action
。
"commands": {
"_execute_browser_action": {
"suggested_key": {
"default": "Ctrl+Shift+U",
"mac": "Alt+Shift+U"
},
"description": "Opens Yurl"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.