gpt4 book ai didi

google-chrome-extension - Chrome 命令 API

转载 作者:行者123 更新时间:2023-12-04 01:59:29 25 4
gpt4 key购买 nike

我已经从使用命令 API 的 Chrome 文档加载了这个示例扩展。

list 文件

{
"name": "Sample Extension Commands extension",
"description": "Press Ctrl+Shift+F (Command+Shift+F on a Mac) to open the browser action popup, press Ctrl+Shift+Y to send an event (Command+Shift+Y on a Mac).",
"version": "1.0",
"manifest_version": 2,
"background": {
"scripts": ["background.js"],
"persistent": false
},
"browser_action": {
"default_popup": "browser_action.html"
},
"commands": {
"toggle-feature": {
"suggested_key": { "default": "Ctrl+Shift+Y" },
"description": "Send a 'toggle-feature' event to the extension"
},
"_execute_browser_action": {
"suggested_key": {
"default": "Ctrl+Shift+F",
"mac": "MacCtrl+Shift+F"
}
}
}
}

背景.js
chrome.commands.onCommand.addListener(function(command) {
console.log('onCommand event received for message: ', command);
});

非常简单,但没有触发监听器回调 - 我在控制台中没有输出,也没有任何错误。如果我使用其他 API,例如选项卡,我的监听器会按预期触发,只是命令 API 对我不起作用。

最佳答案

评论者 rsanchez提供正确答案:

Are you working with an unpacked extension? You need to remove and re-add the extension for suggested shorcut keys to be considered.

关于google-chrome-extension - Chrome 命令 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19599717/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com