From 88cafba445c0ca0be3bf074316617db7dbb898e9 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 2 Jul 2017 08:41:21 -0400 Subject: [PATCH] [firefox] create key elements even if no shortcut assigned --- platform/firefox/vapi-background.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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 !== '' ) {