Add git clone for github

给github克隆地址添加克隆命令

Stan na 23-11-2016. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Add git clone for github
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  给github克隆地址添加克隆命令
// @author       Colin Zeb
// @match        https://github.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var clonebtnselector = "#js-repo-pjax-container > div.container.new-discussion-timeline.experiment-repo-nav > div.repository-content > div.file-navigation.in-mid-page > div.select-menu.get-repo-select-menu.js-menu-container.float-right.select-menu-modal-right > button";
    var clonedomselector = '.form-control.input-monospace.input-sm.js-zeroclipboard-target.js-url-field';
    var toggleselector = '.btn-link.btn-change-protocol.js-toggler-target.float-right';
    var btn = document.querySelector(clonebtnselector);
    if (btn) {
        btn.addEventListener('click', function () {
            setTimeout(function () {
                var res = document.querySelectorAll(clonedomselector);
                var toggle = document.querySelectorAll(toggleselector);
                var clonedom = res;
                var addfunck = function (item) {
                    item.value = "git clone " + item.value;
                };
                //clonedom.value = "git clone " + clonedom.value;
                //console.log('a');
                //var changefunc = function () {
                //    setTimeout(function () {
                //        if (!clonedom.value.startsWith('git clone')) {
                //            clonedom.value = "git clone " + clonedom.value;
                //        }

                //    }, 100);
                //};
                //toggle[0].addEventListener("click", changefunc);
                //toggle[1].addEventListener("click", changefunc);
                addfunck(clonedom[0]);
                addfunck(clonedom[1]);
            });
        });
    }


})();