Files
my-webtoon/Bomtoon_JS/bomtoon.js
2025-05-11 18:58:43 +02:00

41 lines
1.5 KiB
JavaScript

async function downloadImages(blobUrls) {
for (let i = 0; i < blobUrls.length; i++) {
let response = await fetch(blobUrls[i]);
let blob = await response.blob();
let blobUrlObject = URL.createObjectURL(blob);
let indexStr = String(i).padStart(3, "0"); // 生成 3 位数格式
let filename = `${indexStr}.webp`; // e.g., 001.webp
let a = document.createElement("a");
a.href = blobUrlObject;
a.download = filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(blobUrlObject);
console.log(`Downloaded: ${filename}`);
await new Promise(resolve => setTimeout(resolve, 500)); // 避免 Chrome 限制
}
const div = document.querySelector('div.printView > div:not(style)');
const div2 = Array.from(div.children).filter(el => el.tagName.toLowerCase() === 'div')[1];
const div2_1_1 = div2.querySelector('div:nth-of-type(1) > div:nth-of-type(1)');
const count = Array.from(div2_1_1.children).filter(el => {
return el.tagName.toLowerCase() === 'div' &&
el.hasAttribute('width') &&
el.hasAttribute('height');
}).length;
console.log("div2.1.1 下的 <div> 数量为:", count);
console.log(document.title);
}
const blobs = [...document.querySelectorAll("img")]
.map(el => el.src)
.filter(src => src.startsWith("blob:"));
downloadImages(blobs);