Update temp/temp.js

This commit is contained in:
aka paul 2025-10-26 22:55:39 +00:00
parent bd9f5f67e0
commit 4bc5fdd553

View file

@ -110,15 +110,18 @@ async function extractChapters(url) {
return [];
}
}
async function extractText(url) {
try {
const response = await soraFetch(url);
const htmlText = await response.text();
// Extract image URLs using regex
const regex = /'(https:\/\/[^']+\.jpg)'/g;
const matches = [...htmlText.matchAll(regex)];
const imageUrls = matches.map(match => match[1]);
// Generate HTML
const html = `<!DOCTYPE html>
<html lang="en">
<head>
@ -136,47 +139,60 @@ async function extractText(url) {
background: #000;
-webkit-touch-callout: none;
}
.img-container {
width: 100%;
min-height: 1200px;
background: #000;
position: relative;
}
img {
width: 100%;
display: block;
opacity: 0;
transition: opacity 0.3s ease;
-webkit-user-select: none;
position: absolute;
top: 0;
left: 0;
}
img.loaded {
opacity: 1;
position: relative;
}
</style>
</head>
<body>
${imageUrls.map(url => ` <img data-src="${url}" alt="">`).join('\n')}
${imageUrls.map(url => ` <div class="img-container"><img data-src="${url}" alt=""></div>`).join('\n')}
<script>
(function() {
var images = document.querySelectorAll('img[data-src]');
var currentIndex = 0;
var containers = document.querySelectorAll('.img-container');
var loadQueue = [];
var loading = false;
function loadNext() {
if (currentIndex >= images.length) return;
function loadImage(index) {
if (index >= images.length || loading) return;
loading = true;
var img = images[currentIndex];
var img = images[index];
var container = containers[index];
img.src = img.dataset.src;
img.onload = function() {
container.style.minHeight = img.naturalHeight + 'px';
img.classList.add('loaded');
currentIndex++;
loadNext();
loading = false;
loadImage(index + 1);
};
img.onerror = function() {
currentIndex++;
loadNext();
loading = false;
loadImage(index + 1);
};
}
loadNext();
loadNext();
loadNext();
loadImage(0);
})();
</script>
</body>