From 06cfd33e6015216ec70826fd74c8cd5280bb83ca Mon Sep 17 00:00:00 2001 From: Gabe Yuan Date: Sun, 10 Sep 2023 13:56:11 +0800 Subject: [PATCH] add open options shortcut for ext --- public/_locales/en/messages.json | 3 +++ public/_locales/zh_CN/messages.json | 5 ++++- public/manifest.firefox.json | 6 ++++++ public/manifest.json | 6 ++++++ src/background.js | 4 ++++ src/config/index.js | 1 + 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index f3112bd..5dcdd8e 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -10,5 +10,8 @@ }, "toggle_style": { "message": "Toggle Style" + }, + "open_options": { + "message": "Open Options" } } diff --git a/public/_locales/zh_CN/messages.json b/public/_locales/zh_CN/messages.json index ed67e4a..350f342 100644 --- a/public/_locales/zh_CN/messages.json +++ b/public/_locales/zh_CN/messages.json @@ -6,9 +6,12 @@ "message": "一个简约的双语网页翻译扩展 & 油猴脚本" }, "toggle_translate": { - "message": "切换翻译" + "message": "开启翻译" }, "toggle_style": { "message": "切换样式" + }, + "open_options": { + "message": "打开设置" } } diff --git a/public/manifest.firefox.json b/public/manifest.firefox.json index 835f9d7..44b822c 100644 --- a/public/manifest.firefox.json +++ b/public/manifest.firefox.json @@ -33,6 +33,12 @@ "default": "Alt+C" }, "description": "__MSG_toggle_style__" + }, + "openOptions": { + "suggested_key": { + "default": "Alt+O" + }, + "description": "__MSG_open_options__" } }, "permissions": ["", "storage"], diff --git a/public/manifest.json b/public/manifest.json index e632238..79c2e7f 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -34,6 +34,12 @@ "default": "Alt+C" }, "description": "__MSG_toggle_style__" + }, + "openOptions": { + "suggested_key": { + "default": "Alt+O" + }, + "description": "__MSG_open_options__" } }, "permissions": ["storage"], diff --git a/src/background.js b/src/background.js index 35f2f83..bd1d6c9 100644 --- a/src/background.js +++ b/src/background.js @@ -7,6 +7,7 @@ import { MSG_TRANS_TOGGLE_STYLE, CMD_TOGGLE_TRANSLATE, CMD_TOGGLE_STYLE, + CMD_OPEN_OPTIONS, } from "./config"; import { getSettingWithDefault, tryInitDefaultData } from "./libs/storage"; import { trySyncSettingAndRules } from "./libs/sync"; @@ -85,6 +86,9 @@ browser.commands.onCommand.addListener((command) => { case CMD_TOGGLE_STYLE: sendTabMsg(MSG_TRANS_TOGGLE_STYLE); break; + case CMD_OPEN_OPTIONS: + browser.runtime.openOptionsPage(); + break; default: } }); diff --git a/src/config/index.js b/src/config/index.js index 736dd21..ba203e9 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -29,6 +29,7 @@ export const STOKEY_WEBFIXCACHE_PREFIX = `${APP_NAME}_webfixcache_`; export const CMD_TOGGLE_TRANSLATE = "toggleTranslate"; export const CMD_TOGGLE_STYLE = "toggleStyle"; +export const CMD_OPEN_OPTIONS = "openOptions"; export const CLIENT_WEB = "web"; export const CLIENT_CHROME = "chrome";