🏠 Home 

复制网页链接

左键双击页面即可复制页面链接,改善 edge-dev 版不能复制 url 的问题


安装此脚本?
  1. // ==UserScript==
  2. // @name 复制网页链接
  3. // @namespace copy-url
  4. // @description 左键双击页面即可复制页面链接,改善 edge-dev 版不能复制 url 的问题
  5. // @version 1.4
  6. // @author huhan_y@163.com
  7. // @include *
  8. // @noframes
  9. // ==/UserScript==
  10. (function() {
  11. 'use strict';
  12. document.body.addEventListener('dblclick', function() {
  13. if(navigator.clipboard){
  14. navigator.clipboard.writeText(window.location.href);
  15. }else{
  16. var input = document.createElement('input');
  17. document.body.appendChild(input);
  18. input.value = window.location.href;
  19. var selection = window.getSelection();
  20. var range = selection.getRangeAt(0);
  21. input.select();
  22. document.execCommand('copy');
  23. document.body.removeChild(input);
  24. selection.removeAllRanges();
  25. selection.addRange(range);
  26. }
  27. });
  28. })();