Open with VSCode

Support Open Remote Repo in GitHub Code menu!

Από την 03/08/2021. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         Open with VSCode
// @namespace    http://tampermonkey.net/
// @version      2.0.0
// @description  Support Open Remote Repo in GitHub Code menu!
// @author       Sanonz <[email protected]>
// @match        https://github.com/*/*
// @icon         https://github.githubassets.com/pinned-octocat.svg
// @homepage     https://sanonz.github.io
// @supportURL   https://github.com/sanonz
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    function renderGitpod() {
        var ul = document.querySelector('[data-target="get-repo.modal"] > ul');

        var li = document.createElement('li');
        li.className = 'Box-row Box-row--hover-gray p-0 rounded-0';

        var a = document.createElement('a');
        a.className = 'd-flex flex-items-center color-text-primary text-bold no-underline p-3';
        a.rel = 'nofollow';
        a.target = '_blank';
        a.href = `https://gitpod.io/#${location.href}`;

        var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
        svg.setAttribute('width', 14.4);
        svg.setAttribute('height', 16);
        svg.setAttribute('viewBox', '0 0 36 40');
        svg.setAttribute('version', '1.1');
        svg.setAttribute('class', 'octicon mr-3');
        svg.setAttribute('aria-hidden', 'true');

        var path = document.createElementNS(svg.namespaceURI, 'path');
        path.setAttribute('d', 'M21.388,1.992a3.98,3.98,0,0,1-1.452,5.392L8.3,14.118a1,1,0,0,0-.5.868v10.57a1,1,0,0,0,.5.868l9.209,5.33a.975.975,0,0,0,.978,0l9.209-5.33a1,1,0,0,0,.5-.868V18.983l-8.278,4.731a3.876,3.876,0,0,1-5.316-1.5,3.979,3.979,0,0,1,1.481-5.384L27.928,10.06A5.413,5.413,0,0,1,36,14.835V26.359a7.539,7.539,0,0,1-3.742,6.531L21.685,39.009a7.345,7.345,0,0,1-7.369,0L3.742,32.89A7.539,7.539,0,0,1,0,26.359V14.184A7.539,7.539,0,0,1,3.742,7.653L16.064.521A3.876,3.876,0,0,1,21.388,1.992Z');

        var text = document.createTextNode('Open with Gitpod');

        svg.appendChild(path);
        a.appendChild(svg);
        a.appendChild(text);
        li.appendChild(a);
        ul.insertBefore(li, ul.children[0]);
    }

    function renderVScode() {
        var ul = document.querySelector('[data-target="get-repo.modal"] > ul');

        var li = document.createElement('li');
        li.className = 'Box-row Box-row--hover-gray p-0 rounded-0';

        var a = document.createElement('a');
        a.className = 'd-flex flex-items-center color-text-primary text-bold no-underline p-3';
        a.rel = 'nofollow';
        a.href = `vscode://github.remotehub/open?url=${encodeURIComponent(location.href)}`;

        var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
        svg.setAttribute('width', 16);
        svg.setAttribute('height', 16);
        svg.setAttribute('viewBox', '0 0 1024 1024');
        svg.setAttribute('version', '1.1');
        svg.setAttribute('class', 'octicon mr-3');
        svg.setAttribute('aria-hidden', 'true');

        var path = document.createElementNS(svg.namespaceURI, 'path');
        path.setAttribute('d', 'M746.222933 102.239573l-359.799466 330.820267L185.347413 281.4976 102.2464 329.864533l198.20544 182.132054-198.20544 182.132053 83.101013 48.510293 201.076054-151.558826 359.799466 330.676906 175.527254-85.251413V187.4944z m0 217.57952v384.341334l-255.040853-192.177494z');

        var text = document.createTextNode('Open with VSCode');

        svg.appendChild(path);
        a.appendChild(svg);
        a.appendChild(text);
        li.appendChild(a);
        ul.insertBefore(li, ul.children[0]);
    }

    function render() {
        renderVScode();
        renderGitpod();
    }

    window.addEventListener('pjax:complete', function(evt) {
        const pathnames = location.pathname.substr(1).split('/');
        if (pathnames.length === 2) {
            render();
        }
    });

    render();
})();