Skip to content

Commit

Permalink
wip: 更新 mirrors 列表配置
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed Feb 22, 2024
1 parent 82d2b4e commit 7c7b234
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 22 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ GitHub 访问代理助手。一个适合中国大陆用户使用的浏览器油
然后在浏览器地址栏输入如下地址,应当会被油猴插件检测到并跳转到安装确认界面(若未检测到,可手动复制其内容,在油猴插件中新建脚本并填入):

```txt
https://ghproxy.com/https://raw.githubusercontent.com/lzwme/vm-gh-proxy-cn/main/gh-proxy.js
https://mirror.ghproxy.com/https://raw.githubusercontent.com/lzwme/vm-gh-proxy-cn/main/gh-proxy.user.js
```

## 关于 Github 代理访问体验提升的几种策略
Expand All @@ -30,7 +30,7 @@ https://ghproxy.com/https://raw.githubusercontent.com/lzwme/vm-gh-proxy-cn/main/
- `host绑定`:DNS 测速获取 host、host 绑定软件定时更新
- `host 切换管理软件 SwitchHosts`: <brew|scoop> install switchhosts
- `host定时更新`https://gitlab.cn/ineo6/hosts/-/raw/master/next-hosts
- `host定时更新`https://ghproxy.com/https://raw.githubusercontent.com/521xueweihan/GitHub520/main/hosts
- `host定时更新`https://mirror.ghproxy.com/https://raw.githubusercontent.com/521xueweihan/GitHub520/main/hosts
- `浏览器插件网页助手`
- [violentmonkey(油猴插件)](https://violentmonkey.github.io/get-it/)
- [Git Master 插件](https://github.com/ineo6/git-master)
Expand Down
57 changes: 37 additions & 20 deletions gh-proxy.js → gh-proxy.user.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// ==UserScript==
// @name GitHub 访问代理助手
// @namespace lzwme.github.fast
// @author lzwme
// @author renxia (https://lzw.me)
// @homepageURL https://github.com/lzwme/vm-gh-proxy-cn
// @supportURL https://github.com/lzwme/vm-gh-proxy-cn/issues
// @updateURL https://ghproxy.com/github.com/lzwme/vm-gh-proxy-cn/blob/main/gh-proxy.js
// @downloadURL https://ghproxy.com/github.com/lzwme/vm-gh-proxy-cn/blob/main/gh-proxy.js
// @updateURL https://mirror.ghproxy.com/github.com/lzwme/vm-gh-proxy-cn/blob/main/gh-proxy.user.js
// @downloadURL https://mirror.ghproxy.com/github.com/lzwme/vm-gh-proxy-cn/blob/main/gh-proxy.user.js
// @license MIT License
// @description GitHub 访问加速助手。支持 GitHub 的 clone、release/raw/zip 下载加速
// @include *://github.com/*
// @include *://github*
// @include *://hub.fastgit.xyz/*
// @require https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.slim.min.js
// @icon https://github.githubassets.com/favicon.ico
// @version 1.0.4
// @version 1.1.0
// ==/UserScript==

(function () {
Expand All @@ -24,27 +24,36 @@
name: 'gh-net',
desc: 'ghproxy.net 代理',
types: ['clone', 'download', 'raw'],
format: url => `${Mirrors.ghproxy.url}/${url.replace(/^\//, '')}`,
format(url) {
return `${this.url}/${url.replace(/^(https:\/\/github.com)?\//, '')}`;
},
},
ghproxy: {
url: 'https://mirror.ghproxy.com/github.com',
name: 'ghproxy',
desc: 'ghproxy 代理',
types: ['clone', 'download', 'raw'],
format: url => `${Mirrors.ghproxy.url}/${url.replace(/^\//, '')}`,
format(url) {
return `${this.url}/${url.replace(/^(https:\/\/github.com)?\//, '')}`;
},
},
ghproxy1: {
url: 'https://gh.api.99988866.xyz/github.com',
name: 'gh-xyz',
desc: 'ghproxy 代理(演示站)',
types: ['clone', 'download', 'raw'],
format: url => `${Mirrors.ghproxy1.url}/${url.replace(/^\//, '')}`,
format(url) {
return `${this.url}/${url.replace(/^(https:\/\/github.com)?\//, '')}`;
},
},
netnr: {
"url": "https://cors.zme.ink/https://github.com",
"name": "netnr",
"desc": "由@netnr提供",
types: ['mirror', 'raw', 'download'],
xyz201704: {
url: 'https://scoop.201704.xyz/github.com',
name: '201704.xyz',
desc: '开源的 scoop 国内镜像方案',
types: ['raw', 'download'],
format(url) {
return `${this.url}/${url.replace(/^(https:\/\/github.com)?\//, '')}`;
},
},
gitclone: {
"url": "https://gitclone.com/github.com",
Expand Down Expand Up @@ -76,18 +85,24 @@
"desc": "fastgit ssh",
types: ['clone'],
},
fastgitSsh: {
"url": "https://raw.fastgit.org",
"name": "FastGit-raw",
"desc": "fastgit raw",
types: ['raw'],
},
// fastgitSsh: {
// "url": "https://raw.fastgit.org",
// "name": "FastGit-raw",
// "desc": "fastgit raw",
// types: ['raw'],
// },
zhlh6: {
"url": "git@git.zhlh6.cn",
"name": "加速你的Github",
"desc": "利用ucloud提供的GlobalSSH",
types: ['clone'],
},
netnr: {
"url": "https://cors.zme.ink/https://github.com",
"name": "netnr",
"desc": "由@netnr提供",
types: ['mirror', 'download'], // 'raw'
},
// fastgitdl: {
// url: 'https://download.fastgit.org', // todo: only release files、zip
// name: 'fastgit-dl',
Expand Down Expand Up @@ -125,16 +140,18 @@
["https://doc.fastgit.org/", "FastGit,请仔细甄别"],
["https://d.serctl.com", "GitHub中转下载"],
["https://gitee.com/organizations/mirrors/projects", "Gitee 极速下载"],
["https://lzw.me/tools/", '忒有趣工具箱']
];
const MirrorsList = Object.values(Mirrors);

MirrorsList.forEach(item => {
if (!item.format) {
item.format = (href, type) => {
if (type === 'raw' && ['Statically', 'jsDelivr'].includes(item.name)) {
return item.url + href.replace(`${repo}/raw/`, `${repo}@`);
if (type === 'raw' && ['Statically', 'jsDelivr', 'gh-xyz'].includes(item.name)) {
return item.url + href.replace(`${repo}/raw/`, `${repo}@`).replace('https://github.com', '');
}
const sep = item.url.includes('@') ? ':' : '/';
if (item.url.includes('github.com')) return `${item.url}${sep}${href.replace(/^(https:\/\/github.com)?\//, '')}`;
return `${item.url}${sep}${href.replace(/^\//, '')}`;
};
}
Expand Down

0 comments on commit 7c7b234

Please sign in to comment.