Double Click Open GoldenDict

double click to query selected word in goldendict

目前为 2024-03-14 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Double Click Open GoldenDict
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-03-14
  5. // @description double click to query selected word in goldendict
  6. // @icon https://www.google.com/s2/favicons?sz=64&domain=goldendict.org
  7. // @author Leon406
  8. // @license AGPL-3.0-or-later
  9. // @match *://*/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15. const getSelectionText = () => {
  16. let text = getSelection().toString().trim();
  17. if (!!text && /[a-z0-9]/i.test(text)) {
  18. return text;
  19. } else {
  20. return null;
  21. }
  22. };
  23. document.addEventListener("dblclick", e => {
  24. const ev = e.target;
  25. if (ev.nodeName === "INPUT" && ev.getAttribute("type") === "password") {
  26. const v = ev.value
  27. ev.setAttribute("type", "text");
  28. ev.value = v
  29. setTimeout(() => {
  30. ev.setAttribute("type", "password")
  31. }, 5000)
  32. ev.onblur = () => ev.setAttribute("type", "password")
  33. }
  34. window.open("goldendict://" + getSelectionText())
  35. })
  36.  
  37. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址