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.

Revisions

  1. Fog3211 created this gist Apr 1, 2021.
    31 changes: 31 additions & 0 deletions gitlab_download_with_github_desktop.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    // ==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>
    `
    }
    }

    })();