From 79d8556e0f80d9bd70c753ab3ce7e28390545a4b Mon Sep 17 00:00:00 2001 From: cmliu Date: Mon, 18 Nov 2024 02:32:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=87=AA=E5=8A=A8sync?= =?UTF-8?q?=E8=84=9A=E6=9C=AC;=E6=B7=BB=E5=8A=A0Quantumultx=E5=92=8CLoon;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sync.yml | 40 ++++++++++++++++++++++++++++++++++++++ _worker.js | 12 +++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/sync.yml diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 00000000..ae5c2f42 --- /dev/null +++ b/.github/workflows/sync.yml @@ -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 \ No newline at end of file diff --git a/_worker.js b/_worker.js index 5c423aa8..582f915c 100644 --- a/_worker.js +++ b/_worker.js @@ -30,7 +30,7 @@ export default { mytoken = env.TOKEN || mytoken; BotToken = env.TGTOKEN || BotToken; ChatID = env.TGID || ChatID; - TG = env.TG || TG; + TG = env.TG || TG; subconverter = env.SUBAPI || subconverter; if( subconverter.includes("http://") ){ subconverter = subconverter.split("//")[1]; @@ -88,6 +88,10 @@ export default { 订阅格式 = 'singbox'; } else if (userAgent.includes('surge') || ( url.searchParams.has('surge') && !userAgent.includes('subconverter'))){ 订阅格式 = '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 ; @@ -99,6 +103,8 @@ export default { if (url.searchParams.has('clash')) 追加UA = 'clash'; else if(url.searchParams.has('singbox')) 追加UA = 'singbox'; 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); 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`; } 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`; + } 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); try {