register a shortcut for userscript

This commit is contained in:
Gabe Yuan
2023-09-02 00:42:15 +08:00
parent 5ab2910dc7
commit 23eb92853e
3 changed files with 25 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ import { MSG_TRANS_TOGGLE, MSG_TRANS_PUTRULE } from "./config";
import { isIframe } from "./libs/iframe";
import { handlePing, injectScript } from "./libs/gm";
import { matchRule } from "./libs/rules";
import { register } from "@violentmonkey/shortcut";
/**
* 入口函数
@@ -110,6 +111,18 @@ const init = async () => {
}
}
// 注册快捷键
try {
register("a-q", () => {
translator.toggle();
});
register("a-c", () => {
translator.toggleStyle();
});
} catch (err) {
console.log("[shortcut.register", err);
}
// 同步订阅规则
trySyncAllSubRules(setting);
};