我已经在最近的webextension格式中创建了一些扩展名,它的命令定义为:
"commands": {
"mycommand1": {
"suggested_key": {
"default": "Ctrl+Shift+K",
"mac": "MacCtrl+Shift+K",
"linux": "Ctrl+Shift+K",
"windows":"Ctrl+Shift+K"
},
"description": "do something 1"
}
现在,我想赋予用户自定义这些键盘快捷键的能力,但是当我这样做时:
var getCommands = browser.commands.getAll();
getCommands.then(setCommandsSettings);
function setCommandsSettings(commands){
commands.forEach(function(command) {
if(command.name=="mycommand1"){
command.shortcut="MacCtrl+Shift+L";
}
});
}
如果我检查了命令。ShortCut属性,我会发现它已更改为新值,但是仅通过按旧快捷方式来参与命令。难道我做错了什么?FF在运行时更改快捷方式是否支持?
不幸的是,它似乎尚未得到支持(从Firefox 57.0.1开始),但是有一个bug打开了一个允许这样的增强功能:https://bugzilla.mozilla.mozilla.org/show_bug。CGI?id = 1303384