Contextmenu Listener

Google Search Set

  1. // ==UserScript==
  2. // @name Contextmenu Listener
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Google Search Set
  6. // @author You
  7. // @include *
  8. // @grant GM_openInTab
  9. // @run-at document-body
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. let clipboard
  15. document.addEventListener('cliplink',(e)=>{
  16. GM_openInTab(e.data.link+clipboard);});
  17. function getSelectionText() {
  18. var text = "";
  19. if (window.getSelection) {
  20. text = window.getSelection().toString();
  21. } else if (document.selection && document.selection.type != "Control") {
  22. text = document.selection.createRange().text;
  23. }
  24. return text;
  25. }
  26. document.addEventListener('contextmenu', e => {
  27. let selectText=getSelectionText();
  28. if(selectText.length>0){clipboard=selectText; }
  29. else if(e.target.textContent.length>0){clipboard=e.target.textContent;}
  30.  
  31. });
  32. })();

QingJ © 2025

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