FastGit

GitHub Clone or download、releases 下载加速

Version vom 27.06.2020. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         FastGit
// @version      0.5
// @description  GitHub Clone or download、releases 下载加速
// @author       Vhxubo
// @license      MIT
// @icon         https://github.githubassets.com/favicon.ico
// @homepage     https://gist.github.com/vhxubo/d67fbd5bb3b7308b2e3690ca58e12c12
// @namespace    https://gist.github.com/vhxubo/d67fbd5bb3b7308b2e3690ca58e12c12
// @match        https://github.com/*/*
// @grant        none
// @note         2020.06.27_V0.5 适配新版 UI
// @note         2020.05.06_V0.4 新增: zipProxy - zip 下载链接
// ==/UserScript==

(function () {
    'use strict';
    var gitProxy = 'https://hub.fastgit.org';
    var sshProxy = '[email protected]';
    var releaseProxy = 'https://release.fastgit.org';
    var zipProxy = 'https://download.fastgit.org';

    if (window.location.href.indexOf('releases') === -1) {
        var regex = /"((\/.*)+\.zip)"/;
        var domDownload = document.querySelector('span.d-flex')||document.querySelector('get-repo-controller');
        if (domDownload !== null) {
            var oldHtml = domDownload.outerHTML;
            var zipLink = gitProxy + regex.exec(oldHtml)[1];
            var outHtml = oldHtml
            .replace('Clone or download', 'FastGit')
            .replace('Clone', 'FastGit')
            .replace(/https:\/\/github.com/g, gitProxy)
            .replace(regex, zipLink)
            .replace(/[email protected]/g, sshProxy)
            .replace('https%3A%2F%2Fgithub.com', 'https%3A%2F%2Fhub.fastgit.org');

            domDownload.insertAdjacentHTML('afterend', outHtml);
        }
    } else {
        var resDownload = document.querySelectorAll('.Box--condensed a');
        if (resDownload !== null) {
            var i;
            for (i = 0; i < resDownload.length; i++) {
                var resHref = resDownload[i].getAttribute('href');
                if(resHref.indexOf('.zip') === -1) {
                    resDownload[i].insertAdjacentHTML(
                        'afterend',
                        `<a style="cursor: pointer;" href="${
            releaseProxy + resHref
                        }">FastGit Download</a>`
                    );

                } else {
                    resDownload[i].insertAdjacentHTML(
                        'afterend',
                        `<a style="cursor: pointer;" href="${
            zipProxy + resHref
                        }">FastGit Download</a>`
                    );
                }
            }
        }
    }
})();