register a shortcut for userscript
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
"@emotion/styled": "^11.10.8",
|
"@emotion/styled": "^11.10.8",
|
||||||
"@mui/icons-material": "^5.11.11",
|
"@mui/icons-material": "^5.11.11",
|
||||||
"@mui/material": "^5.11.12",
|
"@mui/material": "^5.11.12",
|
||||||
|
"@violentmonkey/shortcut": "^1.3.0",
|
||||||
"query-string": "^8.1.0",
|
"query-string": "^8.1.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { MSG_TRANS_TOGGLE, MSG_TRANS_PUTRULE } from "./config";
|
|||||||
import { isIframe } from "./libs/iframe";
|
import { isIframe } from "./libs/iframe";
|
||||||
import { handlePing, injectScript } from "./libs/gm";
|
import { handlePing, injectScript } from "./libs/gm";
|
||||||
import { matchRule } from "./libs/rules";
|
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);
|
trySyncAllSubRules(setting);
|
||||||
};
|
};
|
||||||
|
|||||||
12
yarn.lock
12
yarn.lock
@@ -1663,7 +1663,7 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@babel/runtime@npm:^7.11.2, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.16.3, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.20.7, @babel/runtime@npm:^7.22.10, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.8.7":
|
"@babel/runtime@npm:^7.11.2, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.16.3, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.20.1, @babel/runtime@npm:^7.20.7, @babel/runtime@npm:^7.22.10, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.8.7":
|
||||||
version: 7.22.11
|
version: 7.22.11
|
||||||
resolution: "@babel/runtime@npm:7.22.11"
|
resolution: "@babel/runtime@npm:7.22.11"
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -3841,6 +3841,15 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@violentmonkey/shortcut@npm:^1.3.0":
|
||||||
|
version: 1.3.0
|
||||||
|
resolution: "@violentmonkey/shortcut@npm:1.3.0"
|
||||||
|
dependencies:
|
||||||
|
"@babel/runtime": ^7.20.1
|
||||||
|
checksum: 5c839c0193014ff29d000337c8cb03f950e5386379a5cc7c845b9e4c566126dc1cfc431b71bc591e30ce7b8a5e82c2fc38396d52b705352252eb0376a7d18fd3
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@webassemblyjs/ast@npm:1.11.6, @webassemblyjs/ast@npm:^1.11.5":
|
"@webassemblyjs/ast@npm:1.11.6, @webassemblyjs/ast@npm:^1.11.5":
|
||||||
version: 1.11.6
|
version: 1.11.6
|
||||||
resolution: "@webassemblyjs/ast@npm:1.11.6"
|
resolution: "@webassemblyjs/ast@npm:1.11.6"
|
||||||
@@ -9516,6 +9525,7 @@ __metadata:
|
|||||||
"@emotion/styled": ^11.10.8
|
"@emotion/styled": ^11.10.8
|
||||||
"@mui/icons-material": ^5.11.11
|
"@mui/icons-material": ^5.11.11
|
||||||
"@mui/material": ^5.11.12
|
"@mui/material": ^5.11.12
|
||||||
|
"@violentmonkey/shortcut": ^1.3.0
|
||||||
query-string: ^8.1.0
|
query-string: ^8.1.0
|
||||||
react: ^18.2.0
|
react: ^18.2.0
|
||||||
react-app-rewired: ^2.2.1
|
react-app-rewired: ^2.2.1
|
||||||
|
|||||||
Reference in New Issue
Block a user