From 77b3b6093f6dcc5f8daf2c9ef50ea9959e8e039e Mon Sep 17 00:00:00 2001 From: Jip Fr Date: Tue, 9 Jul 2024 19:11:30 +0200 Subject: [PATCH 1/2] fix(mangadex): stop proxying for MangaDex --- public/js/pages/reader.js | 24 +++++++++++++----------- src/routers/manga-page.ts | 3 ++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/public/js/pages/reader.js b/public/js/pages/reader.js index 09b76a2..12b30a1 100644 --- a/public/js/pages/reader.js +++ b/public/js/pages/reader.js @@ -421,23 +421,25 @@ function doImages(bypassCache = false) { img.setAttribute("data-i", clone.length - i); img.style.minHeight = "30vh"; + const referer = location.href.includes("mangasee") + ? "mangasee" + : location.href.includes("manganelo") + ? "manganelo" + : location.href.includes("mangahere") + ? "mangahere" + : "null"; + // Set source - const proxySrc = `/proxy-image?url=${encodeURIComponent(url)}&referer=${ - location.href.includes("mangasee") - ? "mangasee" - : location.href.includes("manganelo") - ? "manganelo" - : location.href.includes("mangahere") - ? "mangahere" - : "null" - }${bypassCache ? `&c=${+Date.now()}` : ""}`; + const proxySrc = `/proxy-image?url=${encodeURIComponent( + url + )}&referer=${referer}${bypassCache ? `&c=${+Date.now()}` : ""}`; const isBookMode = getSettings()["double-pages"] === "yes"; if (isBookMode) { - img.setAttribute("src", url.includes("mangadex") ? proxySrc : url); + img.setAttribute("src", url); } else { - img.setAttribute("data-src", url.includes("mangadex") ? proxySrc : url); + img.setAttribute("data-src", url); img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="; } diff --git a/src/routers/manga-page.ts b/src/routers/manga-page.ts index ca41869..7758fc1 100644 --- a/src/routers/manga-page.ts +++ b/src/routers/manga-page.ts @@ -299,7 +299,8 @@ router.get("/proxy-image", (req, res) => { } else if (req.query.referer === "mangahere") { headers.referer = "https://www.mangahere.cc/"; } - headers["user-agent"] = "Adolla"; + headers["user-agent"] = + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"; fetch(url, { headers, From 1c9ae58d69d92b7c206d45715b8b5f7fc73f7ef9 Mon Sep 17 00:00:00 2001 From: Jip Fr Date: Tue, 9 Jul 2024 19:18:16 +0200 Subject: [PATCH 2/2] fix: actually rebuild --- public/js_compiled/pages/reader.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/js_compiled/pages/reader.js b/public/js_compiled/pages/reader.js index 0f87857..d70c73a 100644 --- a/public/js_compiled/pages/reader.js +++ b/public/js_compiled/pages/reader.js @@ -463,14 +463,15 @@ function doImages() { img.setAttribute("alt", "Page ".concat(Number(clone.length - i))); img.setAttribute("data-i", clone.length - i); img.style.minHeight = "30vh"; + var referer = location.href.includes("mangasee") ? "mangasee" : location.href.includes("manganelo") ? "manganelo" : location.href.includes("mangahere") ? "mangahere" : "null"; // Set source - var proxySrc = "/proxy-image?url=".concat(encodeURIComponent(url), "&referer=").concat(location.href.includes("mangasee") ? "mangasee" : location.href.includes("manganelo") ? "manganelo" : location.href.includes("mangahere") ? "mangahere" : "null").concat(bypassCache ? "&c=".concat(+Date.now()) : ""); + var proxySrc = "/proxy-image?url=".concat(encodeURIComponent(url), "&referer=").concat(referer).concat(bypassCache ? "&c=".concat(+Date.now()) : ""); var isBookMode = getSettings()["double-pages"] === "yes"; if (isBookMode) { - img.setAttribute("src", url.includes("mangadex") ? proxySrc : url); + img.setAttribute("src", url); } else { - img.setAttribute("data-src", url.includes("mangadex") ? proxySrc : url); + img.setAttribute("data-src", url); img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="; } img.addEventListener("error", function () {