Github Clone URL Username Adder

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

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name				Github Clone URL Username Adder
// @id					github-clone-url-username-adder
// @namespace			github-username-adder

// @description			Adds username to clone URL and a button to clone using TortoiseGit
// @version				0.1.1
// @screenshot			http://i.imgur.com/9pRgUAU.png

// @author				KOLANICH
// @copyright			KOLANICH, 2014
// @contributionURL		http://userscripts.org/scripts/show/308033
// @contributionAmount	feel free to contribute

// @include				/https?://github.com/[\w_ -]+/.+/?/
// @grant				none
// @noframes			1
// @run-at				document-idle
// @optimize			1
// ==/UserScript==
const githubForWindowsPrefix="github-windows://openRepo/";
const tortoiseGitPrefix="tgit://clone/";
try{
	var authorName=document.getElementsByName("octolytics-dimension-user_login")[0].content;
	var cloneURLBox=document.querySelector('[data-protocol-type="http"]').getElementsByTagName("INPUT")[0];
	var link=document.createElement("A");
	link.href=cloneURLBox.value;
	link.username=authorName;
	cloneURLBox.value=link.href;
	link.href=tortoiseGitPrefix+link.href;
	link.className="minibutton sidebar-button";
	link.innerHTML="<span class=\"octicon octicon-device-desktop\"></span> Clone to TortoiseGit";
	var cloneGHBtn=document.getElementsByClassName("clone-options")[0].nextElementSibling;
	cloneGHBtn.href=cloneGHBtn.href.substring(githubForWindowsPrefix.length);
	cloneGHBtn.username=authorName;
	cloneGHBtn.href=githubForWindowsPrefix+cloneGHBtn.href;
	cloneGHBtn.parentNode.insertBefore(link,cloneGHBtn.nextElementSibling);
	delete cloneGHBtn;
	delete cloneURLBox;
	delete link;
	delete authorName;
}catch(err){
	console.error(err);
}