GitHubSourceTree

Adds a "Clone in SourceTree" button to github pages

Fra 31.07.2014. Se den seneste versjonen.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name       GitHubSourceTree
// @namespace  http://really-serious.biz/
// @version    1.0.3
// @description  Adds a "Clone in SourceTree" button to github pages
// @respository  https://github.com/jamesgarfield/GitHubSourceTree
// @match https://*github.com/*
// @licence MIT(3)
// @copyright  2014+, James Garfield
// ==/UserScript==

(function(){
    const $ = document.querySelectorAll.bind(document);
    
    const gitHubNode = $(".clone-options + a")[0]

    if (!gitHubNode) {
    	return;
    }

    const parentNode = gitHubNode.parentNode;
    const insertBeforeNode = gitHubNode.nextSibling;
    const gitURL = $(".clone-url-box .js-url-field")[0].value
    
    var sourceTreeNode = gitHubNode.cloneNode();
    sourceTreeNode.href = 'sourcetree://cloneRepo/' + gitURL;
    sourceTreeNode.innerHTML = '<span class="octicon octicon-device-desktop"></span>Clone in SourceTree';
    
    parentNode.insertBefore(sourceTreeNode, insertBeforeNode);
    
})()