Следуя сценарию в https://gist.github.com/zbraniecki/000268ea27154bbccaad190dd479d226. Я пишу рабочий код (по крайней мере, в моем Firefox) ниже
manifest.json
{
"applications": {
"gecko": {
"id": "selecttab@braniecki.net",
"strict_min_version": "48.0"
}
},
"manifest_version": 2,
"name": "SelectTab Gnome Shortcut Override",
"version": "1.0",
"description": "An extension that overrides the default select-tab modifier key.",
"permissions": ["tabs"],
"background": {
"scripts": ["background.js"]
},
"commands": {
"selectTab1": {
"suggested_key": { "default": "Alt+1" },
"description": "Activate Tab 1"
},
"selectTab2": {
"suggested_key": { "default": "Alt+2" },
"description": "Activate Tab 2"
},
"selectTab3": {
"suggested_key": { "default": "Alt+3" },
"description": "Activate Tab 3"
},
"selectTab4": {
"suggested_key": { "default": "Alt+4" },
"description": "Activate Tab 4"
},
"selectTab5": {
"suggested_key": { "default": "Alt+5" },
"description": "Activate Tab 5"
},
"selectTab6": {
"suggested_key": { "default": "Alt+6" },
"description": "Activate Tab 6"
},
"selectTab7": {
"suggested_key": { "default": "Alt+7" },
"description": "Activate Tab 7"
},
"selectTab8": {
"suggested_key": { "default": "Alt+8" },
"description": "Activate Tab 8"
},
"selectTab9": {
"suggested_key": { "default": "Alt+9" },
"description": "Activate Tab 9"
}
}
}
backgroud.js
browser.commands.onCommand.addListener(async (command) => {
let num = parseInt(command.substr(9, 10)) - 1;
let tabs = await browser.tabs.query({currentWindow: true});
if (tabs.length < num) {
return;
}
if (num === 8) {
browser.tabs.update(tabs[tabs.length-1].id, {active: true});
} else {
browser.tabs.update(tabs[num].id, {active: true});
}
});
Тогда вы можете обратиться к Как опубликовать FireFox WebExtension только для локальной установки? , чтобы установить его навсегда.