FastGit

GitHub Clone or download、releases 下载加速

目前为 2020-04-30 提交的版本。查看 最新版本

// ==UserScript==
// @name         FastGit
// @namespace    https://gist.github.com/vhxubo/d67fbd5bb3b7308b2e3690ca58e12c12
// @version      0.2
// @description  GitHub Clone or download、releases 下载加速
// @author       Vhxubo
// @license      MIT
// @homepage     https://gist.github.com/vhxubo/d67fbd5bb3b7308b2e3690ca58e12c12
// @match        https://github.com/*/*
// @grant        none
// ==/UserScript==

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

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

            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');
                resDownload[i].insertAdjacentHTML(
                    'afterend',
                    `<a style="cursor: pointer;" href="${
            releaseProxy + resHref
                    }">FastGit Download</a>`
        );
            }
        }
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址