mirror of
https://github.com/lush2020/CF-Workers-SUB.git
synced 2026-03-21 02:34:04 +08:00
加入自动sync脚本;添加Quantumultx和Loon;
This commit is contained in:
40
.github/workflows/sync.yml
vendored
Normal file
40
.github/workflows/sync.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
name: Upstream Sync
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 0 * * *" # every day
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync_latest_from_upstream:
|
||||||
|
name: Sync latest commits from upstream repo
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.event.repository.fork }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Step 1: run a standard checkout action
|
||||||
|
- name: Checkout target repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# Step 2: run the sync action
|
||||||
|
- name: Sync upstream changes
|
||||||
|
id: sync
|
||||||
|
uses: aormsby/Fork-Sync-With-Upstream-action@v3.4
|
||||||
|
with:
|
||||||
|
upstream_sync_repo: cmliu/CF-Workers-SUB
|
||||||
|
upstream_sync_branch: main
|
||||||
|
target_sync_branch: main
|
||||||
|
target_repo_token: ${{ secrets.GITHUB_TOKEN }} # automatically generated, no need to set
|
||||||
|
|
||||||
|
# Set test_mode true to run tests instead of the true action!!
|
||||||
|
test_mode: false
|
||||||
|
|
||||||
|
- name: Sync check
|
||||||
|
if: failure()
|
||||||
|
run: |
|
||||||
|
echo "[Error] 由于上游仓库的 workflow 文件变更,导致 GitHub 自动暂停了本次自动更新,你需要手动 Sync Fork 一次,详细教程请查看项目README.md "
|
||||||
|
echo "[Error] Due to a change in the workflow file of the upstream repository, GitHub has automatically suspended the scheduled automatic update. You need to manually sync your fork. Please refer to the project README.md for instructions. "
|
||||||
|
exit 1
|
||||||
12
_worker.js
12
_worker.js
@@ -30,7 +30,7 @@ export default {
|
|||||||
mytoken = env.TOKEN || mytoken;
|
mytoken = env.TOKEN || mytoken;
|
||||||
BotToken = env.TGTOKEN || BotToken;
|
BotToken = env.TGTOKEN || BotToken;
|
||||||
ChatID = env.TGID || ChatID;
|
ChatID = env.TGID || ChatID;
|
||||||
TG = env.TG || TG;
|
TG = env.TG || TG;
|
||||||
subconverter = env.SUBAPI || subconverter;
|
subconverter = env.SUBAPI || subconverter;
|
||||||
if( subconverter.includes("http://") ){
|
if( subconverter.includes("http://") ){
|
||||||
subconverter = subconverter.split("//")[1];
|
subconverter = subconverter.split("//")[1];
|
||||||
@@ -88,6 +88,10 @@ export default {
|
|||||||
订阅格式 = 'singbox';
|
订阅格式 = 'singbox';
|
||||||
} else if (userAgent.includes('surge') || ( url.searchParams.has('surge') && !userAgent.includes('subconverter'))){
|
} else if (userAgent.includes('surge') || ( url.searchParams.has('surge') && !userAgent.includes('subconverter'))){
|
||||||
订阅格式 = 'surge';
|
订阅格式 = 'surge';
|
||||||
|
} else if (userAgent.includes('quantumult%20x') || (url.searchParams.has('quanx') && !userAgent.includes('subconverter'))){
|
||||||
|
订阅格式 = 'quanx';
|
||||||
|
} else if (userAgent.includes('loon') || (url.searchParams.has('loon') && !userAgent.includes('subconverter'))){
|
||||||
|
订阅格式 = 'loon';
|
||||||
}
|
}
|
||||||
|
|
||||||
let subconverterUrl ;
|
let subconverterUrl ;
|
||||||
@@ -99,6 +103,8 @@ export default {
|
|||||||
if (url.searchParams.has('clash')) 追加UA = 'clash';
|
if (url.searchParams.has('clash')) 追加UA = 'clash';
|
||||||
else if(url.searchParams.has('singbox')) 追加UA = 'singbox';
|
else if(url.searchParams.has('singbox')) 追加UA = 'singbox';
|
||||||
else if(url.searchParams.has('surge')) 追加UA = 'surge';
|
else if(url.searchParams.has('surge')) 追加UA = 'surge';
|
||||||
|
else if(url.searchParams.has('quanx')) 追加UA = 'Quantumult%20X';
|
||||||
|
else if(url.searchParams.has('loon')) 追加UA = 'Loon';
|
||||||
|
|
||||||
const 请求订阅响应内容 = await getSUB(urls ,request ,追加UA, userAgentHeader);
|
const 请求订阅响应内容 = await getSUB(urls ,request ,追加UA, userAgentHeader);
|
||||||
console.log(请求订阅响应内容);
|
console.log(请求订阅响应内容);
|
||||||
@@ -159,6 +165,10 @@ export default {
|
|||||||
subconverterUrl = `${subProtocol}://${subconverter}/sub?target=singbox&url=${encodeURIComponent(订阅转换URL)}&insert=false&config=${encodeURIComponent(subconfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&new_name=true`;
|
subconverterUrl = `${subProtocol}://${subconverter}/sub?target=singbox&url=${encodeURIComponent(订阅转换URL)}&insert=false&config=${encodeURIComponent(subconfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&new_name=true`;
|
||||||
} else if (订阅格式 == 'surge'){
|
} else if (订阅格式 == 'surge'){
|
||||||
subconverterUrl = `${subProtocol}://${subconverter}/sub?target=surge&url=${encodeURIComponent(订阅转换URL)}&insert=false&config=${encodeURIComponent(subconfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&new_name=true`;
|
subconverterUrl = `${subProtocol}://${subconverter}/sub?target=surge&url=${encodeURIComponent(订阅转换URL)}&insert=false&config=${encodeURIComponent(subconfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&new_name=true`;
|
||||||
|
} else if (订阅格式 == 'quanx'){
|
||||||
|
subconverterUrl = `${subProtocol}://${subconverter}/sub?target=quanx&url=${encodeURIComponent(订阅转换URL)}&insert=false&config=${encodeURIComponent(subconfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false&udp=true`;
|
||||||
|
} else if (订阅格式 == 'loon'){
|
||||||
|
subconverterUrl = `${subProtocol}://${subconverter}/sub?target=loon&url=${encodeURIComponent(订阅转换URL)}&insert=false&config=${encodeURIComponent(subconfig)}&emoji=true&list=false&tfo=false&scv=true&fdn=false&sort=false`;
|
||||||
}
|
}
|
||||||
//console.log(订阅转换URL);
|
//console.log(订阅转换URL);
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user