GitHub Clone Prefix

Add "git clone " before the clone URL on GitHub repository pages, making it ready for direct copying and use.

  1. // ==UserScript==
  2. // @name GitHub Clone Prefix
  3. // @name:zh-CN Github上的clone前面加命令
  4. // @name:en GitHub Clone Prefix
  5. // @namespace http://tampermonkey.net/
  6. // @version 2.0
  7. // @description:zh-CN 在 GitHub 代码仓库页面的克隆地址前添加 "git clone ",复制即可用(对,这几个字都懒得打)
  8. // @description:en Add "git clone " before the clone URL on GitHub repository pages, making it ready for direct copying and use.
  9. // @author Yog-Sothoth
  10. // @match https://github.com/*/*
  11. // @grant none
  12. // @license MIT
  13. // @run-at document-idle
  14. // @description Add "git clone " before the clone URL on GitHub repository pages, making it ready for direct copying and use.
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. function modifyInputAndButton() {
  19. let inputElem = document.querySelector("#clone-with-https");
  20. let buttonElem = inputElem?.closest("div")?.querySelector("button");
  21. if (!inputElem || !buttonElem) return false;
  22. if (!inputElem.value.startsWith("git clone ")) inputElem.value = "git clone " + inputElem.value;
  23. buttonElem.addEventListener("click", async (e) => {
  24. e.stopImmediatePropagation();
  25. await navigator.clipboard.writeText(inputElem.value);
  26. }, true);
  27. return true;
  28. }
  29. if (!modifyInputAndButton()) {
  30. let observer = new MutationObserver(() => {
  31. if (modifyInputAndButton()) observer.disconnect();
  32. });
  33. observer.observe(document.body, { childList: true, subtree: true });
  34. }
  35. })();
  36.  
  37.  
  38.  

QingJ © 2025

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