diff --git a/src/js/commands.js b/src/js/commands.js index 8e7dfb4e9..8994e84c8 100644 --- a/src/js/commands.js +++ b/src/js/commands.js @@ -37,7 +37,20 @@ if ( µBlock.canUpdateShortcuts ) { self.addEventListener( 'webextFlavor', - ( ) => { µBlock.canUpdateShortcuts = vAPI.webextFlavor.major < 74; }, + ( ) => { + const µb = µBlock; + µb.canUpdateShortcuts = vAPI.webextFlavor.major < 74; + if ( µb.canUpdateShortcuts === false ) { return; } + vAPI.storage.get('commandShortcuts').then(bin => { + if ( bin instanceof Object === false ) { return; } + const shortcuts = bin.commandShortcuts; + if ( Array.isArray(shortcuts) === false ) { return; } + µb.commandShortcuts = new Map(shortcuts); + for ( const [ name, shortcut ] of shortcuts ) { + vAPI.commands.update({ name, shortcut }); + } + }); + }, { once: true } ); } diff --git a/src/js/start.js b/src/js/start.js index 82f52a047..79f8b3f96 100644 --- a/src/js/start.js +++ b/src/js/start.js @@ -95,17 +95,6 @@ const initializeTabs = async function() { /******************************************************************************/ -const onCommandShortcutsReady = function(commandShortcuts) { - if ( Array.isArray(commandShortcuts) === false ) { return; } - µb.commandShortcuts = new Map(commandShortcuts); - if ( µb.canUpdateShortcuts === false ) { return; } - for ( const entry of commandShortcuts ) { - vAPI.commands.update({ name: entry[0], shortcut: entry[1] }); - } -}; - -/******************************************************************************/ - // To bring older versions up to date const onVersionReady = function(lastVersion) { @@ -204,7 +193,6 @@ const onFirstFetchReady = function(fetched) { fromFetch(µb.restoreBackupSettings, fetched); onNetWhitelistReady(fetched.netWhitelist); onVersionReady(fetched.version); - onCommandShortcutsReady(fetched.commandShortcuts); }; /******************************************************************************/ @@ -226,7 +214,6 @@ const fromFetch = function(to, fetched) { const createDefaultProps = function() { const fetchableProps = { - 'commandShortcuts': [], 'dynamicFilteringString': [ 'behind-the-scene * * noop', 'behind-the-scene * image noop',