contextmenu

context menu

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/534404/1580108/contextmenu.js

  1. ;(() => {
  2. const userAgent = navigator.userAgent.toLowerCase();
  3. const goldDictKey = parseKey(GM_getValue('goldDictKey', 'ctrl c,ctrl c'));
  4. const ocrKey = parseKey(GM_getValue('ocrKey', ['windows', 'win32', 'win64'].filter(v => userAgent.indexOf(v) > -1).length > 0 ? 'cmd alt c' : 'alt c'));
  5. const menus = GM_getValue('menus', [
  6. {
  7. title: 'ocr translate',
  8. action: {next: goldDictKey, prev: ocrKey},
  9. key: 'h',
  10. path: 'aca'
  11. },
  12. {
  13. title: "ocr",
  14. action: ocrKey,
  15. key: "k"
  16. },
  17. {
  18. title: "parse qrcode",
  19. action: 'ctrl alt x',
  20. key: "x"
  21. },
  22. {
  23. title: "anki",
  24. action: () => {
  25. addAnki('', tapKeyboard);
  26. },
  27. key: "a"
  28. },
  29. /*{
  30. title: "sh",
  31. action: {
  32. cmd: "ls -l /var/log/!*.log",
  33. },
  34. key: "e",
  35. path: "cmd",
  36. call: (res) => {
  37. console.log(res.response)
  38. },
  39. }*/
  40. /*{
  41. title: "env",
  42. action: {
  43. cmd: ["env","grep","wc"],
  44. args: [],
  45. "1": ["PATH"],
  46. "2": ["-l"],
  47. env: ["PATH=$PATH:/home/xing"]
  48. },
  49. key: "e",
  50. path: "cmd",
  51. call: (res) => {
  52. console.log(res.response)
  53. },
  54. }*/
  55. /*{
  56. title: "ls",
  57. action: {cmd: "ls", args: ["-l", "/"]},
  58. key: "e",
  59. path: "cmd",
  60. call: (res) => {
  61. console.log(res.response)
  62. },
  63. }*/
  64. ]);
  65. PushContextMenu(...menus);
  66. })();