commit
This commit is contained in:
31
KakaoPage_JS/kakaopage.js
Normal file
31
KakaoPage_JS/kakaopage.js
Normal file
@@ -0,0 +1,31 @@
|
||||
async function downloadImages(urls) {
|
||||
for (let i = 0; i < urls.length; i++) {
|
||||
const url = urls[i];
|
||||
|
||||
try {
|
||||
// 尝试抓取并转成 Blob
|
||||
const response = await fetch(url, { mode: 'cors' });
|
||||
const blob = await response.blob();
|
||||
|
||||
// 创建临时链接并强制下载
|
||||
const blobUrl = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = blobUrl;
|
||||
a.download = `image_${i + 1}.jpg`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(blobUrl); // 清理资源
|
||||
|
||||
console.log(`✅ 下载成功: ${url}`);
|
||||
} catch (err) {
|
||||
console.error(`❌ 下载失败: ${url}`, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const links = Array.from(document.querySelectorAll('img'))
|
||||
.map(img => img.src)
|
||||
.filter(src => src.startsWith('https://page-edge.kakao.com/sdownload/resource?kid='));
|
||||
|
||||
downloadImages(links);
|
||||
Reference in New Issue
Block a user