Give Me! "Git Clone"

When copying the URL in the Code section in Github, it adds "git clone" to the copied url.

目前为 2023-10-05 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Give Me! "Git Clone"
  3. // @namespace https://antidote.day
  4. // @version 0.3
  5. // @description When copying the URL in the Code section in Github, it adds "git clone" to the copied url.
  6. // @author Antidote
  7. // @match https://github.com/*/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function runWhenReady(readySelector, callback) {
  16. var numAttempts = 0;
  17. var tryNow = function() {
  18. var elem = document.querySelector(readySelector);
  19. if (elem) {
  20. callback(elem);
  21. } else {
  22. numAttempts++;
  23. if (numAttempts >= 34) {
  24. console.warn('Giving up after 34 attempts. Could not find: ' + readySelector);
  25. } else {
  26. setTimeout(tryNow, 250 * Math.pow(1.1, numAttempts));
  27. }
  28. }
  29. };
  30. tryNow();
  31. }
  32.  
  33. function Inject() {
  34. var inputElement = document.querySelector("#local-panel > ul > li:nth-child(1) > tab-container > div:nth-child(2) > div > input");
  35. var copyElement = document.querySelector("#local-panel > ul > li:nth-child(1) > tab-container > div:nth-child(2) > div > div > clipboard-copy");
  36. inputElement.value = "git clone " + inputElement.value;
  37. copyElement.value = inputElement.value;
  38. }
  39.  
  40. runWhenReady('#local-panel > ul > li:nth-child(1) > tab-container > div:nth-child(2) > div > input', Inject);
  41. })();

QingJ © 2025

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