SourceTree Clone for GitLab

Add a "clone with sourcetree" button to GitLab, if you're into that sort of thing

Από την 28/07/2020. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         SourceTree Clone for GitLab
// @namespace    https://sanin.dev
// @version      0.1
// @description  Add a "clone with sourcetree" button to GitLab, if you're into that sort of thing
// @author       Cory Sanin
// @match        *://gitlab.com/*
// @grant        none
// @icon         https://www.sourcetreeapp.com/assets/img/favicons/sourcetree/android-chrome-192x192.png
// ==/UserScript==

(function() {
    'use strict';
    var clonemenu = document.querySelector('ul.clone-options-dropdown');
    if(clonemenu){
        var li = document.createElement('li');
        li.classList.add('pt-2');
        var child;
        child = document.createElement('label');
        child.classList.add('label-bold');
        child.innerText = 'Clone with SourceTree';
        li.appendChild(child);
        child = document.createElement('div');
        child.classList.add('input-group');
        var btn = document.createElement('a');
        btn.classList.add('btn', 'btn-primary');
        btn.style.width = '100%';
        btn.innerText = 'Clone In SourceTree'
        btn.tabIndex = 0;
        btn.href = `sourcetree://cloneRepo?type=stash&baseWebUrl=${encodeURIComponent(window.location.origin)}&cloneUrl=${encodeURIComponent(document.getElementById('ssh_project_clone').value)}`;
        child.appendChild(btn);
        li.appendChild(child);
        clonemenu.appendChild(li);
    }
})();