From a8833749ccc17af6d27ecadcfb1ec8a2d901bfe3 Mon Sep 17 00:00:00 2001 From: Ryosuke Asano Date: Sat, 7 Oct 2023 14:10:42 +0900 Subject: [PATCH] [FB] CSK | Add custom actions --- browser/app/profile/000-floorp.js | 5 +++++ browser/base/content/browser-custom-keyboard-shortcut.js | 8 ++++++++ browser/components/CustomKeyboardShortcutUtils.sys.mjs | 7 +++++++ 3 files changed, 20 insertions(+) diff --git a/browser/app/profile/000-floorp.js b/browser/app/profile/000-floorp.js index eea15ffe..86383352 100644 --- a/browser/app/profile/000-floorp.js +++ b/browser/app/profile/000-floorp.js @@ -153,6 +153,11 @@ pref("floorp.titlebar.favicon.color", false); pref("floorp.custom.shortcutkeysAndActions", "[]"); pref("floorp.custom.shortcutkeysAndActions.enabled", true); pref("floorp.custom.shortcutkeysAndActions.remove.fx.actions", false); +pref("floorp.custom.shortcutkeysAndActions.customAction1", ""); +pref("floorp.custom.shortcutkeysAndActions.customAction2", ""); +pref("floorp.custom.shortcutkeysAndActions.customAction3", ""); +pref("floorp.custom.shortcutkeysAndActions.customAction4", ""); +pref("floorp.custom.shortcutkeysAndActions.customAction5", ""); // Profile Manager pref("floorp.browser.profile-manager.enabled", true); diff --git a/browser/base/content/browser-custom-keyboard-shortcut.js b/browser/base/content/browser-custom-keyboard-shortcut.js index b32310ab..40434807 100644 --- a/browser/base/content/browser-custom-keyboard-shortcut.js +++ b/browser/base/content/browser-custom-keyboard-shortcut.js @@ -131,4 +131,12 @@ const buildShortCutkeyFunctions = { }, }; + +let customActionsFunctions = { + evalCustomeActionWithNum(num) { + let action = Services.prefs.getStringPref(`floorp.custom.shortcutkeysAndActions.customAction${num}`); + Function(action)(); + } +} + buildShortCutkeyFunctions.init(); diff --git a/browser/components/CustomKeyboardShortcutUtils.sys.mjs b/browser/components/CustomKeyboardShortcutUtils.sys.mjs index 11ee71f6..44baa2be 100644 --- a/browser/components/CustomKeyboardShortcutUtils.sys.mjs +++ b/browser/components/CustomKeyboardShortcutUtils.sys.mjs @@ -153,6 +153,13 @@ export const keyboradShortcutActions = { // Workspace actions openNextWorkspace: ["workspaceFunctions.manageWorkspaceFunctions.changeWorkspaceToBeforeNext();", "open-next-workspace", "workspace-action"], openPreviousWorkspace: ["workspaceFunctions.manageWorkspaceFunctions.changeWorkspaceToAfterNext();", "open-previous-workspace", "workspace-action"], + + // Custom actions + customAction1: ["customActionsFunctions.evalCustomeActionWithNum(1)", "custom-action-1", "custom-action"], + customAction2: ["customActionsFunctions.evalCustomeActionWithNum(2)", "custom-action-2", "custom-action"], + customAction3: ["customActionsFunctions.evalCustomeActionWithNum(3)", "custom-action-3", "custom-action"], + customAction4: ["customActionsFunctions.evalCustomeActionWithNum(4)", "custom-action-4", "custom-action"], + customAction5: ["customActionsFunctions.evalCustomeActionWithNum(5)", "custom-action-5", "custom-action"] } export const modifiersList = {