适合「经常在网页上点下载」的人:装一个油猴脚本,GitHub 页面上的下载链接自动变成镜像直链,无需每次复制粘贴到工具站。
安装
- 浏览器装 Tampermonkey(Chrome / Edge / Firefox / Safari 均有)。
- 新建脚本,粘贴下面代码,保存。
- 打开任意 GitHub 仓库 / Release 页,下载链接即已替换为镜像地址(鼠标悬停可见)。
脚本
// ==UserScript==
// @name GitHub 镜像加速下载
// @namespace mirrordl
// @version 1.0
// @description 把 GitHub 的 Release/Raw/压缩包链接替换为镜像加速地址
// @match https://github.com/*
// @grant none
// ==/UserScript==
(function () {
const MIRROR = 'https://gh-proxy.com/'; // 可换 ghproxy.net / ghproxy.vip 等
const RE = /^https:\/\/(github\.com\/[^/]+\/[^/]+\/(releases\/download|archive)\/|raw\.githubusercontent\.com\/)/;
function rewrite() {
document.querySelectorAll('a[href]').forEach((a) => {
const href = a.href;
if (RE.test(href) && !href.startsWith(MIRROR)) {
a.href = MIRROR + href;
a.title = '镜像加速: ' + href;
}
});
}
rewrite();
// GitHub 是 SPA / 动态加载,监听 DOM 变化
new MutationObserver(rewrite).observe(document.body, { childList: true, subtree: true });
})();