From fe8dda676b8e340b7e4c16f043fd58cf204def17 Mon Sep 17 00:00:00 2001 From: wood chen <95951386+woodchen-ink@users.noreply.github.com> Date: Tue, 16 Jan 2024 21:59:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=93=BE=E6=8E=A5=EF=BC=8Cvi?= =?UTF-8?q?deo=E9=83=A8=E5=88=86=E6=94=B9=E5=8F=98=E6=9D=83=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- url/video/all.csv | 7 +++++++ worker 302跳转.js | 13 ++++--------- worker 不跳转.js | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/url/video/all.csv b/url/video/all.csv index e85d63f..1f9ac47 100644 --- a/url/video/all.csv +++ b/url/video/all.csv @@ -1,2 +1,9 @@ https://cdn-img.czl.net/woodchenink/2024/1/16/%E6%B5%AA%E5%AE%A2%E5%89%91%E5%BF%83%E8%BF%BD%E5%BF%86%E7%AF%8730%E5%B8%A71080P%E6%97%A0%E5%A3%B0%E9%9F%B3.mp4 +https://t.mwm.moe/acg/acg +https://t.mwm.moe/acg/acg +https://t.mwm.moe/acg/acg +https://t.mwm.moe/acg/acg +https://t.mwm.moe/acg/acg +https://t.mwm.moe/acg/acg +https://t.mwm.moe/acg/acg https://t.mwm.moe/acg/acg \ No newline at end of file diff --git a/worker 302跳转.js b/worker 302跳转.js index 95a49aa..448da32 100644 --- a/worker 302跳转.js +++ b/worker 302跳转.js @@ -1,5 +1,5 @@ // 外部 JSON 文件的 URL -const CSV_PATHS_URL = 'https://raw.githubusercontent.com/woodchen-ink/Random-Api/master/url.json'; +const CSV_PATHS_URL = 'https://raw.githubusercontent.com/woodchen-ink/Random-Api/main/url.json'; addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)); @@ -36,19 +36,14 @@ async function handleRequest(request) { const randomIndex = Math.floor(Math.random() * fileArray.length); const randomUrl = fileArray[randomIndex]; - // 用原请求的头部创建新的请求对象 - const resourceRequest = new Request(randomUrl, { - headers: request.headers - }); - - // 直接从随机 URL 获取图片内容并返回 - return fetch(resourceRequest); + // 返回302重定向到randomUrl,1更快,2方便排查 + return Response.redirect(randomUrl, 302); } else { return new Response('CSV file could not be fetched.', { status: 500 }); } } else { // 如果不是 CSV 资源路径,返回 index.html 内容 - const indexHtmlResponse = await fetch('https://raw.githubusercontent.com/woodchen-ink/Random-Api/master/index.html'); + const indexHtmlResponse = await fetch('https://raw.githubusercontent.com/woodchen-ink/Random-Api/main/index.html'); return new Response(indexHtmlResponse.body, { headers: { 'Content-Type': 'text/html' }, }); diff --git a/worker 不跳转.js b/worker 不跳转.js index 95a49aa..f13ed34 100644 --- a/worker 不跳转.js +++ b/worker 不跳转.js @@ -1,5 +1,5 @@ // 外部 JSON 文件的 URL -const CSV_PATHS_URL = 'https://raw.githubusercontent.com/woodchen-ink/Random-Api/master/url.json'; +const CSV_PATHS_URL = 'https://raw.githubusercontent.com/woodchen-ink/Random-Api/main/url.json'; addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)); @@ -48,7 +48,7 @@ async function handleRequest(request) { } } else { // 如果不是 CSV 资源路径,返回 index.html 内容 - const indexHtmlResponse = await fetch('https://raw.githubusercontent.com/woodchen-ink/Random-Api/master/index.html'); + const indexHtmlResponse = await fetch('https://raw.githubusercontent.com/woodchen-ink/Random-Api/main/index.html'); return new Response(indexHtmlResponse.body, { headers: { 'Content-Type': 'text/html' }, });