Give Me! "Git Clone"

It is a user script that allows adding git clone to the url with repository from Github.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Give Me! "Git Clone"
// @namespace    https://antidote.day
// @version      0.2
// @description  It is a user script that allows adding git clone to the url with repository from Github.
// @author       Antidote
// @match        https://github.com/*/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=github.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function runWhenReady(readySelector, callback) {
        var numAttempts = 0;
        var tryNow = function() {
            var elem = document.querySelector(readySelector);
            if (elem) {
                callback(elem);
            } else {
                numAttempts++;
                if (numAttempts >= 34) {
                    console.warn('Giving up after 34 attempts. Could not find: ' + readySelector);
                } else {
                    setTimeout(tryNow, 250 * Math.pow(1.1, numAttempts));
                }
            }
        };
        tryNow();
    }

    function Inject() {
        var inputElement = document.querySelector("#local-panel > ul > li:nth-child(1) > tab-container > div:nth-child(2) > div > input");
        var copyElement = document.querySelector("#local-panel > ul > li:nth-child(1) > tab-container > div:nth-child(2) > div > div > clipboard-copy");
        inputElement.value = "git clone " + inputElement.value;
        copyElement.value = inputElement.value;
    }

    runWhenReady('#local-panel > ul > li:nth-child(1) > tab-container > div:nth-child(2) > div > input', Inject);
})();