Google Chrome扩展程序开发问题

问题描述 投票:0回答:1

我出于自己的目的在做自己的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设置,但所有操作均无效。感觉有些设置或历史记录或保存的密码,或者从Google帐户同步的任何内容都与这些键绑定冲突。我必须提到,例如,如果我将某些按键绑定更改为Alt + Z,则适用于我的Google帐户。因此问题仅在于Alt + 1 ... 9键

google-chrome google-chrome-extension google-account
1个回答
0
投票

原来该页面chrome:// extensions / shortcuts可以提供帮助。分配丢失的键绑定绰绰有余]

© www.soinside.com 2019 - 2024. All rights reserved.