Double Click Open GoldenDict

double click to query selected word in goldendict

  1. // ==UserScript==
  2. // @name Double Click Open GoldenDict
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-03-22
  5. // @description double click to query selected word in goldendict
  6. // @note only support English
  7. // @icon https://www.google.com/s2/favicons?sz=64&domain=goldendict.org
  8. // @author Leon406
  9. // @license AGPL-3.0-or-later
  10. // @match *://*/*
  11. // @grant GM_registerMenuCommand
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. 'use strict';
  16. // 支持全选,改为 true
  17. const selectAll = false
  18. const getSelectionText = () => {
  19. let text = getSelection().toString().trim();
  20.  
  21. if (!!text && ( selectAll|| /^[a-z']+$/i.test(text))) {
  22. return text;
  23. } else {
  24. return null;
  25. }
  26. };
  27. document.addEventListener("dblclick", e => {
  28. let text = getSelectionText()
  29. if (text) {
  30. window.open("goldendict://" + text)
  31. }
  32. })
  33. })();

QingJ © 2025

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