[firefox] create key elements even if no shortcut assigned

This commit is contained in:
gorhill 2017-07-02 08:41:21 -04:00
parent 7aab05f00a
commit 88cafba445
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 4 additions and 9 deletions

View File

@ -3435,19 +3435,14 @@ vAPI.commands = (function() {
var myKey, shortcut, parts, modifiers, key;
for ( var command of commands ) {
modifiers = key = '';
shortcut = vAPI.localStorage.getItem('shortcuts.' + command.id);
if ( shortcut === null ) {
vAPI.localStorage.setItem('shortcuts.' + command.id, '');
} else if ( (parts = /^((?:[a-z]+-){1,})?(\w)$/.exec(shortcut)) !== null ) {
modifiers = (parts[1] || '').slice(0, -1).replace(/-/g, ',');
key = parts[2] || '';
}
if ( typeof shortcut !== 'string' ) { continue; }
parts = /^((?:[a-z]+-){1,})?(\w)$/.exec(shortcut);
if ( parts === null ) { continue; }
modifiers = parts[1];
if ( typeof modifiers === 'string' ) {
modifiers = parts[1].slice(0, -1).split('-').join(' ');
}
key = parts[2];
if ( typeof key !== 'string' ) { continue; }
myKey = doc.createElement('key');
myKey.setAttribute('id', 'uBlock0Key-' + command.id);
if ( modifiers !== '' ) {