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
bd9f5f67e0
commit
4bc5fdd553
1 changed files with 28 additions and 12 deletions
40
temp/temp.js
40
temp/temp.js
|
|
@ -110,15 +110,18 @@ async function extractChapters(url) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function extractText(url) {
|
async function extractText(url) {
|
||||||
try {
|
try {
|
||||||
const response = await soraFetch(url);
|
const response = await soraFetch(url);
|
||||||
const htmlText = await response.text();
|
const htmlText = await response.text();
|
||||||
|
|
||||||
|
// Extract image URLs using regex
|
||||||
const regex = /'(https:\/\/[^']+\.jpg)'/g;
|
const regex = /'(https:\/\/[^']+\.jpg)'/g;
|
||||||
const matches = [...htmlText.matchAll(regex)];
|
const matches = [...htmlText.matchAll(regex)];
|
||||||
const imageUrls = matches.map(match => match[1]);
|
const imageUrls = matches.map(match => match[1]);
|
||||||
|
|
||||||
|
// Generate HTML
|
||||||
const html = `<!DOCTYPE html>
|
const html = `<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
|
@ -136,47 +139,60 @@ async function extractText(url) {
|
||||||
background: #000;
|
background: #000;
|
||||||
-webkit-touch-callout: none;
|
-webkit-touch-callout: none;
|
||||||
}
|
}
|
||||||
|
.img-container {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 1200px;
|
||||||
|
background: #000;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
img {
|
img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: block;
|
display: block;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: opacity 0.3s ease;
|
transition: opacity 0.3s ease;
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
}
|
}
|
||||||
img.loaded {
|
img.loaded {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<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>
|
<script>
|
||||||
(function() {
|
(function() {
|
||||||
var images = document.querySelectorAll('img[data-src]');
|
var images = document.querySelectorAll('img[data-src]');
|
||||||
var currentIndex = 0;
|
var containers = document.querySelectorAll('.img-container');
|
||||||
|
var loadQueue = [];
|
||||||
|
var loading = false;
|
||||||
|
|
||||||
function loadNext() {
|
function loadImage(index) {
|
||||||
if (currentIndex >= images.length) return;
|
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.src = img.dataset.src;
|
||||||
|
|
||||||
img.onload = function() {
|
img.onload = function() {
|
||||||
|
container.style.minHeight = img.naturalHeight + 'px';
|
||||||
img.classList.add('loaded');
|
img.classList.add('loaded');
|
||||||
currentIndex++;
|
loading = false;
|
||||||
loadNext();
|
loadImage(index + 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
img.onerror = function() {
|
img.onerror = function() {
|
||||||
currentIndex++;
|
loading = false;
|
||||||
loadNext();
|
loadImage(index + 1);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
loadNext();
|
loadImage(0);
|
||||||
loadNext();
|
|
||||||
loadNext();
|
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue