Clone in VSCode

Clone Github respository in VSCode

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

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         Clone in VSCode
// @namespace    https://github.com/spacemeowx2
// @version      0.2
// @description  Clone Github respository in VSCode
// @author       space
// @match        https://github.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function createButton(actions, uri) {
        const li = document.createElement('li');
        const button = document.createElement('button');
        button.className = 'btn btn-sm'; // js-toggler-target
        button.innerText = 'Clone in VSCode';
        button.addEventListener('click', () => {
            location.href = `vscode://vscode.git/clone?url=${encodeURIComponent(uri)}`
        })
        li.append(button);
        actions.append(li);
    }
    function getGitUri() {
        const [emptyUri] = [...document.querySelectorAll('button.js-git-protocol-clone-url')].map(i => i.getAttribute('data-url')).filter(i => i.startsWith('git'))
        const [normalUri] = [...document.querySelectorAll('input[data-autoselect]')].map(i => i.value).filter(i => i.startsWith('git'))
        return emptyUri || normalUri
    }
    const actions = document.querySelector('.pagehead-actions')
    if (actions) {
        const uri = getGitUri();
        if (uri) {
            createButton(actions, uri);
        }
    }
})();