mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-21 21:26:19 +01:00
Update temp/temp.js
This commit is contained in:
parent
54e9346a62
commit
d35d45b8a8
1 changed files with 58 additions and 0 deletions
58
temp/temp.js
58
temp/temp.js
|
|
@ -116,6 +116,64 @@ async function extractText(url) {
|
||||||
const response = await soraFetch(url);
|
const response = await soraFetch(url);
|
||||||
const htmlText = await response.text();
|
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) {
|
} catch (error) {
|
||||||
console.error("❌ Error in extractImages:", error);
|
console.error("❌ Error in extractImages:", error);
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue