Update temp/temp.js

This commit is contained in:
aka paul 2025-10-26 22:48:56 +00:00
parent 54e9346a62
commit d35d45b8a8

View file

@ -115,7 +115,65 @@ async function extractText(url) {
try {
const response = await soraFetch(url);
const htmlText = await response.text();
const regex = /'(https:\/\/[^']+\.jpg)'/g;
const matches = [...htmlText.matchAll(regex)];
const imageUrls = matches.map(match => match[1]);
const html = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Manga</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #000;
}
img {
width: 100%;
display: block;
opacity: 0;
transition: opacity 0.3s ease;
}
img.loaded {
opacity: 1;
}
</style>
</head>
<body>
${imageUrls.map(url => ` <img data-src="${url}" alt="">`).join('\n')}
<script>
const imageObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const img = entry.target;
img.src = img.dataset.src;
img.onload = () => {
img.classList.add('loaded');
};
observer.unobserve(img);
}
});
}, {
rootMargin: '200px'
});
document.querySelectorAll('img[data-src]').forEach(img => {
imageObserver.observe(img);
});
</script>
</body>
</html>`;
return html;
} catch (error) {
console.error("❌ Error in extractImages:", error);
return {