github 镜像加速访问

通过访问镜像站点来提速访问 github,获取页面上可下载的 zip 文件,走第三方的加速服务快速下载

目前為 2022-01-05 提交的版本,檢視 最新版本

// ==UserScript==
// @name         github 镜像加速访问
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  通过访问镜像站点来提速访问 github,获取页面上可下载的 zip 文件,走第三方的加速服务快速下载
// @author       You
// @match        *://*/*
// @icon         https://img2.baidu.com/it/u=4226010475,2406859093&fm=26&fmt=auto
// @grant        GM_registerMenuCommand
// @grant        GM_openInTab
// @require      https://code.jquery.com/jquery-3.1.1.min.js
// ==/UserScript==

(function() {
    var mirror_url1 = "https://" + "github.com.cnpmjs.org";
    var mirror_url2 = "https://" + "hub.fastgit.org";
    var mirror_url3 = "https://" + "github.wuyanzheshui.workers.dev";
    GM_registerMenuCommand(` ⚠ 请勿在镜像站登陆个人账号 ⚠`, function() {})
    GM_registerMenuCommand(`📗 打开github 镜像站 1`, function() {
        window.GM_openInTab(mirror_url1, {
            active: true,
            insert: true,
            setParent: true
        });
    })
    GM_registerMenuCommand(`📘 打开github 镜像站 2`, function() {
        window.GM_openInTab(mirror_url2, {
            active: true,
            insert: true,
            setParent: true
        });
    })
    // 查找页面上的 “下载zip” 按钮,获取到url,替换为镜像地址,再调用下载操作
    GM_registerMenuCommand(`⏬ 加速下载 zip 文件`, function() {
        let $arr = $('a[href$=".zip"]');
        if ($arr.length == 0) {
            alert(`当前页面没有找到 zip 下载包`);
        } else if ($arr.length == 1) {
            downZip($arr.find(':first').attr('href'))
        } else {
            let divId = 'github-down-zip-list';
            $('#' + divId).remove();
            let div = `<div id="${divId}"></div>`;
            $('body').append(div);
            $('#' + divId).css({
                width: '300px',
                height: '200px',
                position: 'fixed',
                'z-index': '9999',
                background: '#fff',
                left: window.innerWidth / 2 - 200 + 'px',
                top: window.innerHeight / 2 - 150 + 'px',
                'border-radius': '3px',
                'box-shadow': '0 0 5px',
                overflow: 'overlay',
            })
            $('#' + divId).append(`<div style="  padding: 10px;
                color: red;
                cursor: pointer;
                border-bottom: 1px solid #0006;
                font-weight: bold;
                text-align: center;
                position: fixed;
                width: 300px;
                z-index: 999;
                background: #fff;">关闭</div>`)
            $('#' + divId).append(`<div style="padding:10px;">1</div>`)
            $('#' + divId).find('div:first').click(function() {
                $('#' + divId).remove();
            })
            let downUrl = 'https://shrill-pond-3e81.hunsh.workers.dev/https://github.com/';
            $arr.each(function() {
                let href = downUrl + $(this).attr('href');
                let text = $(this).text() + ' [ ' + href.substr(href.lastIndexOf('/') + 1)+' ]';
                let div = `<a style="padding:10px;display: block;border-bottom: 1px solid #0006;" href="${href}">${text}</a>`;
                $('#' + divId).append(div);
            })
        }
    })

    function downZip(url) {
        window.GM_openInTab(url, {
            active: true,
            insert: true,
            setParent: true
        });
    }

})();

QingJ © 2025

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