browser-cmd-hotkeys.js 489 B

12345678910111213141516171819202122
  1. /* global prefs */
  2. 'use strict';
  3. /*
  4. Registers hotkeys in FF
  5. */
  6. (() => {
  7. const hotkeyPrefs = prefs.knownKeys.filter(k => k.startsWith('hotkey.'));
  8. prefs.subscribe(hotkeyPrefs, updateHotkey, {runNow: true});
  9. async function updateHotkey(name, value) {
  10. try {
  11. name = name.split('.')[1];
  12. if (value.trim()) {
  13. await browser.commands.update({name, shortcut: value});
  14. } else {
  15. await browser.commands.reset(name);
  16. }
  17. } catch (e) {}
  18. }
  19. })();