快速将 GitHub 项目下载到本地
目前為
// ==UserScript==
// @name Open With Visual Studio Code
// @name:en Open With Visual Studio Code
// @version 1.0.0
// @description 快速将 GitHub 项目下载到本地
// @description:en Quickly download github project to local
// @author hoorn
// @license MIT
// @compatible chrome Latest
// @compatible firefox Latest
// @compatible edge Latest
// @noframes
// @grant window.onurlchange
// @match https://github.com/*
// @namespace https://greasyfork.org/users/1276388
// ==/UserScript==
(() => {
"use strict";
const $ = document.querySelector.bind(document);
function openWithVSCode() {
const actions = $('.pagehead-actions');
if (actions == null || $('#openwithvscode-button')) return;
const btnHTML = '<li><a id="openwithvscode-button" class="btn btn-sm" target="_blank">Open With Visual Studio Code</a></li>';
actions.insertAdjacentHTML('afterBegin', btnHTML);
const button = document.getElementById('openwithvscode-button');
if (button) {
button.addEventListener('click', function () {
var url = window.location.href;
var projectUrl = url + ".git";
var vscodeUrl = "vscode://vscode.git/clone?url=" + projectUrl;
window.open(vscodeUrl);
});
}
}
openWithVSCode();
})()
;