Skip to content

Instantly share code, notes, and snippets.

@Fog3211
Created April 1, 2021 06:33
Show Gist options
  • Save Fog3211/11d7d654d1531fce4a63ea0ee57c8e3c to your computer and use it in GitHub Desktop.
Save Fog3211/11d7d654d1531fce4a63ea0ee57c8e3c to your computer and use it in GitHub Desktop.
在gitlab中使用github desktop下载代码
// ==UserScript==
// @name gitlab download
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 在gitlab中使用github desktop下载代码
// @author Fog3211
// @match *://gitlab.com/*
// @icon https://about.gitlab.com/ico/favicon.ico
// @grant none
// ==/UserScript==
(function () {
'use strict';
const gitCloneContainer = document.querySelectorAll('.git-clone-holder')[0]
if (gitCloneContainer) {
const GitLinkLists = [...gitCloneContainer.querySelectorAll('.input-group-btn .dropdown-menu li a')]
if (GitLinkLists.length >= 2) {
const targetLink = `x-github-client://openRepo/${GitLinkLists[1].href.replace('.git','')}`
gitCloneContainer.innerHTML += `
<div class="input-group-btn" style="margin-left:10px;">
<button class="btn btn-clipboard" data-clipboard-target="#project_clone" type="button">
<a href="${targetLink}">使用GitHub Desktop下载</a>
</button>
</div>
`
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment