quick proxy sanity
This commit is contained in:
@@ -372,6 +372,8 @@
|
|||||||
const READER_MODE_KEY = "reader_view_mode";
|
const READER_MODE_KEY = "reader_view_mode";
|
||||||
const HISTORY_KEY = "reading_history";
|
const HISTORY_KEY = "reading_history";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// --- Initialization ---
|
// --- Initialization ---
|
||||||
function init() {
|
function init() {
|
||||||
const pathParts = window.location.pathname.split("/");
|
const pathParts = window.location.pathname.split("/");
|
||||||
@@ -587,6 +589,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add this helper right above preloadInitialImages()
|
||||||
|
function proxyUrl(src) {
|
||||||
|
if (!src || src.startsWith("/")) return src; // already relative/proxied
|
||||||
|
return `${serverUrl}/proxy-image?url=${encodeURIComponent(src)}`;
|
||||||
|
}
|
||||||
|
|
||||||
async function preloadInitialImages() {
|
async function preloadInitialImages() {
|
||||||
// Create all IMG elements first (lazy loading structure)
|
// Create all IMG elements first (lazy loading structure)
|
||||||
imageLinks.forEach((src) => {
|
imageLinks.forEach((src) => {
|
||||||
@@ -603,7 +611,7 @@
|
|||||||
// Detect Aspect Ratio on first image for Auto-Webtoon Mode
|
// Detect Aspect Ratio on first image for Auto-Webtoon Mode
|
||||||
if (toPreload[0]) {
|
if (toPreload[0]) {
|
||||||
const tempImg = new Image();
|
const tempImg = new Image();
|
||||||
tempImg.src = imageLinks[0];
|
tempImg.src = proxyUrl(imageLinks[0]);
|
||||||
await new Promise(r => {
|
await new Promise(r => {
|
||||||
tempImg.onload = () => {
|
tempImg.onload = () => {
|
||||||
// If height is significantly larger than width (2x), assume Webtoon
|
// If height is significantly larger than width (2x), assume Webtoon
|
||||||
@@ -624,7 +632,7 @@
|
|||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
img.onload = resolve;
|
img.onload = resolve;
|
||||||
img.onerror = resolve;
|
img.onerror = resolve;
|
||||||
img.src = imageLinks[index];
|
img.src = proxyUrl(imageLinks[index]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -642,7 +650,7 @@
|
|||||||
function loadRemainingImages() {
|
function loadRemainingImages() {
|
||||||
const images = container.getElementsByTagName("img");
|
const images = container.getElementsByTagName("img");
|
||||||
Array.from(images).slice(4).forEach((img, index) => {
|
Array.from(images).slice(4).forEach((img, index) => {
|
||||||
img.src = imageLinks[index + 4];
|
img.src = proxyUrl(imageLinks[index + 4]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user