1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-05 18:32:30 +01:00

Update kbd shortcuts only if kbd shortcuts pane is enabled

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/386#issuecomment-611806957
This commit is contained in:
Raymond Hill 2020-04-10 17:25:36 -04:00
parent 9e7dd7a2c3
commit a7dc0de98f
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 14 additions and 14 deletions

View File

@ -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 }
);
}

View File

@ -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',