我在最近的 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";
}
});
}
如果我检查 command.shortcut 属性,我会看到它已更改为新值,但是只有按下旧的快捷方式才会涉及命令。难道我做错了什么? FF是否支持在运行时更改快捷方式?
最佳答案
不幸的是,它似乎还不受支持(从 Firefox 57.0.1 开始),但是有一个 bug 打开以允许这样的增强:https://bugzilla.mozilla.org/show_bug.cgi?id=1303384
关于javascript - Firefox (57.0.1) 是否支持从 javascript 设置 Web 扩展中的命令快捷键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47620137/