为了我自己的目的,我正在做我自己的chrome扩展。此扩展已成功运行5个月。很可能这不是扩展代码的问题。
我的manifest.json (我在mac上工作)
"manifest_version": 2,
"name": "tab-switch-pt2",
"description": "use option(alt) + 1...9 to change current tab. 9 — always last tab",
"version": "1.0.0",
"background": {
"scripts": ["background.js"],
"persistent": true
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
],
"commands": {
"my-change-tab:4": {
"suggested_key": {
"default": "Alt+4",
"mac": "Alt+4"
},
"description": "Change to tab number 4"
},
"my-change-tab:7": {
"suggested_key": {
"default": "Alt+7",
"mac": "Alt+7"
},
"description": "Change to tab number 7"
},
"my-change-tab:5": {
"suggested_key": {
"default": "Alt+5",
"mac": "Alt+5"
},
"description": "Change to tab number 5"
},
"my-change-tab:8": {
"suggested_key": {
"default": "Alt+8",
"mac": "Alt+8"
},
"description": "Change to tab number 8"
}
},
"permissions": ["tabs", "activeTab", "http://*/*", "https://*/*"]
}基本上,它监听Alt+(1...9)键,并更改选项卡。一个问题是这些密钥绑定不起作用。
chrome.commands.getAll((...args) => console.log(args, 'args'));返回以下内容
[
[
{ description: 'Change to tab number 4', name: 'my-change-tab:4', shortcut: '' },
{ description: 'Change to tab number 5', name: 'my-change-tab:5', shortcut: '' },
{ description: 'Change to tab number 7', name: 'my-change-tab:7', shortcut: '' },
{ description: 'Change to tab number 8', name: 'my-change-tab:8', shortcut: '' },
],
]这是我使用其他所有chrome扩展登录到我的google帐户的时候。我认为这是扩展的问题所在。下面是我所做的:
创建了新用户,安装了我的扩展,并且运行正常。上面相同命令的输出:
[
[
{ description: 'Change to tab number 4', name: 'my-change-tab:4', shortcut: '⌥4' },
{ description: 'Change to tab number 5', name: 'my-change-tab:5', shortcut: '⌥5' },
{ description: 'Change to tab number 7', name: 'my-change-tab:7', shortcut: '⌥7' },
{ description: 'Change to tab number 8', name: 'my-change-tab:8', shortcut: '⌥8' },
],
]所以这些快捷键对我来说是有效的。我已经在我的google账户上安装了所有的扩展,但它仍然工作得很好。只有当我登录(从这个新的google用户)到我自己的google帐户,并且当所有同步完成时,我的扩展停止工作。我试着重装chrome并重置chrome设置,但都不起作用。这感觉像是一些设置,历史记录,保存的密码,或任何从谷歌账户同步的东西都与这些键绑定冲突。例如,我必须指出,如果我将一些键绑定更改为Alt+Z --它适用于我的谷歌帐户。所以问题只出现在Alt+1...9密钥上
发布于 2020-04-14 02:35:00
事实证明,页面chrome://扩展/快捷方式可能会有所帮助。分配缺少的键绑定就足够了
https://stackoverflow.com/questions/61194022
复制相似问题