diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index 3b8a1a7ec..b5901ec8b 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -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 !== '' ) {