mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-07 03:12:33 +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:
parent
9e7dd7a2c3
commit
a7dc0de98f
@ -37,7 +37,20 @@
|
|||||||
if ( µBlock.canUpdateShortcuts ) {
|
if ( µBlock.canUpdateShortcuts ) {
|
||||||
self.addEventListener(
|
self.addEventListener(
|
||||||
'webextFlavor',
|
'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 }
|
{ once: true }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -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
|
// To bring older versions up to date
|
||||||
|
|
||||||
const onVersionReady = function(lastVersion) {
|
const onVersionReady = function(lastVersion) {
|
||||||
@ -204,7 +193,6 @@ const onFirstFetchReady = function(fetched) {
|
|||||||
fromFetch(µb.restoreBackupSettings, fetched);
|
fromFetch(µb.restoreBackupSettings, fetched);
|
||||||
onNetWhitelistReady(fetched.netWhitelist);
|
onNetWhitelistReady(fetched.netWhitelist);
|
||||||
onVersionReady(fetched.version);
|
onVersionReady(fetched.version);
|
||||||
onCommandShortcutsReady(fetched.commandShortcuts);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
@ -226,7 +214,6 @@ const fromFetch = function(to, fetched) {
|
|||||||
|
|
||||||
const createDefaultProps = function() {
|
const createDefaultProps = function() {
|
||||||
const fetchableProps = {
|
const fetchableProps = {
|
||||||
'commandShortcuts': [],
|
|
||||||
'dynamicFilteringString': [
|
'dynamicFilteringString': [
|
||||||
'behind-the-scene * * noop',
|
'behind-the-scene * * noop',
|
||||||
'behind-the-scene * image noop',
|
'behind-the-scene * image noop',
|
||||||
|
Loading…
Reference in New Issue
Block a user