Github Clone URL Username Adder

Adds username to clone URL and a button to clone using TortoiseGit

当前为 2014-09-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Github Clone URL Username Adder
  3. // @id github-clone-url-username-adder
  4. // @namespace github-username-adder
  5.  
  6. // @description Adds username to clone URL and a button to clone using TortoiseGit
  7. // @version 0.1.1
  8. // @screenshot http://i.imgur.com/9pRgUAU.png
  9.  
  10. // @author KOLANICH
  11. // @copyright KOLANICH, 2014
  12. // @contributionURL http://userscripts.org/scripts/show/308033
  13. // @contributionAmount feel free to contribute
  14.  
  15. // @include /https?://github.com/[\w_ -]+/.+/?/
  16. // @grant none
  17. // @noframes 1
  18. // @run-at document-idle
  19. // @optimize 1
  20. // ==/UserScript==
  21. const githubForWindowsPrefix="github-windows://openRepo/";
  22. const tortoiseGitPrefix="tgit://clone/";
  23. try{
  24. var authorName=document.getElementsByName("octolytics-dimension-user_login")[0].content;
  25. var cloneURLBox=document.querySelector('[data-protocol-type="http"]').getElementsByTagName("INPUT")[0];
  26. var link=document.createElement("A");
  27. link.href=cloneURLBox.value;
  28. link.username=authorName;
  29. cloneURLBox.value=link.href;
  30. link.href=tortoiseGitPrefix+link.href;
  31. link.className="minibutton sidebar-button";
  32. link.innerHTML="<span class=\"octicon octicon-device-desktop\"></span> Clone to TortoiseGit";
  33. var cloneGHBtn=document.getElementsByClassName("clone-options")[0].nextElementSibling;
  34. cloneGHBtn.href=cloneGHBtn.href.substring(githubForWindowsPrefix.length);
  35. cloneGHBtn.username=authorName;
  36. cloneGHBtn.href=githubForWindowsPrefix+cloneGHBtn.href;
  37. cloneGHBtn.parentNode.insertBefore(link,cloneGHBtn.nextElementSibling);
  38. delete cloneGHBtn;
  39. delete cloneURLBox;
  40. delete link;
  41. delete authorName;
  42. }catch(err){
  43. console.error(err);
  44. }