手把手教你如何批量自动下载即梦 AI 生图的高清图片

目录

一、安装篡改猴(Tampermonkey)

二、在篡改猴里添加脚本

三、即梦 AI 使用

功能介绍

​​​​​​手把手教你如何批量自动下载即梦 AI 生图的高清图片https://mp.weixin.qq.com/s/EvKf8P1G-hEwM0tkd7W2lQ?token=1155579505&lang=zh_CN

今天给大家分享一个超实用的技巧,能让你在下载即梦高清图片时变得超轻松!这个秘密武器就是篡改猴(Tampermonkey),它是浏览器扩展中的神器呢!

一、安装篡改猴(Tampermonkey)

首先,得把篡改猴安装到你的浏览器里。直接打开官网,根据自己使用的浏览器安装相应的版本。

💡

官网:https://www.tampermonkey.net/

比如我用的是 Chrome,就把 crx 文件下载好,然后打开 Chrome 的扩展页,把下载好的文件拖进去,搞定!

💡

Chrome 的文件:https://www.tampermonkey.net/crx/tampermonkey_stable.crx

二、在篡改猴里添加脚本

安装好篡改猴后,点击浏览器扩展程序中的“篡改猴”。

接着,点击“添加新脚本”,把我提供的脚本粘贴进去。

这一步操作完,再打开即梦 AI 生图,你会发现即梦网页的顶部多了一个下载图片的辅助工具。

想学习这个脚本怎么编写可以参考告别繁琐!用tampermonkey批量下载即梦HD图片文章

批量下载即梦图片的脚本:

版本无法使用请关注:

// ==UserScript==

// @name 下载即梦HD(webp)图片

// @namespace http://tampermonkey.net/

// @version 1.0

// @description Collect and download specific image URLs containing aigc_resize:2400:2400 and labeled as '超清' from the page

// @match https://jimeng.jianying.com/*

// @grant GM_setClipboard

// @grant GM_download

// @author WxAiWay

// ==/UserScript==

(function() {

'use strict';

classImageCollector {

constructor() {

this.collectedUrls = [];

this.downloadPrefix = '';

this.startIndex = 1;

this.copyBtn = null;

this.downloadDelay = 1000; // 默认下载延迟

this.isDownloading = false;

this.progressBar = null;

}

init() {

this.createControlPanel();

this.observeImages();

}

decodeHTMLEntities(text) {

const textArea = document.createElement('textarea');

textArea.innerHTML = text;

return textArea.value;

}

getImageUrl(img) {

let src = img.getAttribute('src');

if (src) {

src = this.decodeHTMLEntities(src);

if (src.includes('aigc_resize:2400:2400')) {

return src;

}

}

returnnull;

}

createControlPanel() {

const panel = document.createElement('div');

panel.style.cssText = `

position: fixed;

top: 0;

left: 50%;

transform: translateX(-50%);

background: white;

border: 1px solid black;

border-top: none;

padding: 10px;

z-index: 10000;

box-shadow: 0 2px 5px rgba(0,0,0,0.2);

border-radius: 0 0 5px 5px;

cursor: move;

`;

const dragHandle = document.createElement('div');

dragHandle.style.cssText = `

width: 100%;

height: 10px;

background: #ddd;

margin-bottom: 5px;

cursor: move;

`;

panel.appendChild(dragHandle);

const prefixInput = document.createElement('input');

prefixInput.type = 'text';

prefixInput.placeholder = '输入文件名前缀';

prefixInput.style.marginRight = '5px';

prefixInput.addEventListener('change', (e) => {

this.downloadPrefix = e.target.value;

});

const startInput = document.createElement('input');

startInput.type = 'number';

startInput.min = 1;

startInput.value = this.startIndex;

startInput.placeholder = '起始索引';

startInput.style.marginRight = '5px';

startInput.addEventListener('change', (e) => {

this.startIndex = parseInt(e.target.value, 10) || 1;

});

const delayInput = document.createElement('input');

delayInput.type = 'number';

delayInput.min = 100;

delayInput.value = this.downloadDelay;

delayInput.placeholder = '下载延迟(ms)';

delayInput.style.marginRight = '5px';

delayInput.addEventListener('change', (e) => {

this.downloadDelay = parseInt(e.target.value, 10) || 1000;

});

const collectBtn = this.createButton('重新收集图片', () =>this.collectImages());

const downloadBtn = this.createButton('批量下载', () =>this.downloadImages());

this.copyBtn = this.createCopyButton();

this.progressBar = document.createElement('div');

this.progressBar.style.cssText = `

width: 100%;

height: 5px;

background-color: #f0f0f0;

margin-top: 5px;

display: none;

`;

const progressInner = document.createElement('div');

progressInner.style.cssText = `

width: 0%;

height: 100%;

background-color: #4CAF50;

transition: width 0.3s;

`;

this.progressBar.appendChild(progressInner);

panel.appendChild(dragHandle);

panel.appendChild(prefixInput);

panel.appendChild(startInput);

panel.appendChild(delayInput);

panel.appendChild(collectBtn);

panel.appendChild(downloadBtn);

panel.appendChild(this.copyBtn);

panel.appendChild(this.progressBar);

document.body.appendChild(panel);

this.makeDraggable(panel, dragHandle);

}

createButton(text, onClick) {

const button = document.createElement('button');

button.textContent = text;

button.style.marginRight = '5px';

button.addEventListener('click', onClick);

return button;

}

createCopyButton() {

returnthis.createButton(`复制URLs (${this.collectedUrls.length})`, () =>this.copyUrls());

}

updateCopyButtonText() {

if (this.copyBtn) {

this.copyBtn.textContent = `复制URLs (${this.collectedUrls.length})`;

}

}

collectImages() {

this.collectedUrls = [];

document.querySelectorAll('.container-EdniD0').forEach(container => {

const imgElement = container.querySelector('.image-mh68Se');

const metaRightElements = container.querySelectorAll('.metaRight-fF8GZJ');

const editSection = document.querySelector('.container-RBbKMJ');

const disabledHDButton = editSection ? editSection.querySelector('.optItem-iyWnC2.disabled-R018rY') : null;

let isHD = false;

// 检查是否有"超清"标识

for (const metaRight of metaRightElements) {

if (metaRight.textContent.trim() === '超清') {

isHD = true;

break;

}

}

// 如果没有"超清"标识,检查编辑区是否有不可用的超清按钮

if (!isHD && disabledHDButton) {

const buttonText = disabledHDButton.textContent.trim();

if (buttonText === '超清') {

isHD = true;

}

}

if (isHD) {

let url = this.getImageUrl(imgElement);

if (url && !this.collectedUrls.includes(url)) {

this.collectedUrls.push(url);

console.log('收集图片URL:', url);

}

}

});

this.showNotification(`已重新收集 ${this.collectedUrls.length} 个符合条件的图片URL`);

this.updateCopyButtonText();

}

copyUrls() {

const urlList = this.collectedUrls.join('\n');

GM_setClipboard(urlList);

this.showNotification(`已复制 ${this.collectedUrls.length} 个URL到剪贴板`);

}

downloadImages() {

if (this.isDownloading) {

this.showNotification('下载已在进行中');

return;

}

this.isDownloading = true;

let downloadedCount = 0;

constdownloadNext = (index) => {

if (index >= this.collectedUrls.length) {

this.isDownloading = false;

this.showNotification(`全部 ${this.collectedUrls.length} 张图片下载完成`);

this.updateProgressIndicator(0, 1); // 重置进度条

return;

}

const url = this.collectedUrls[index];

GM_download({

url: url,

name: `${this.downloadPrefix}${this.startIndex + index}.webp`,

onload: () => {

console.log(`Downloaded: ${this.downloadPrefix}${this.startIndex + index}.webp`);

downloadedCount++;

this.updateProgressIndicator(downloadedCount, this.collectedUrls.length);

setTimeout(() =>downloadNext(index + 1), this.downloadDelay);

},

onerror: (error) => {

console.error(`Error downloading ${this.downloadPrefix}${this.startIndex + index}.webp:`, error);

setTimeout(() =>downloadNext(index + 1), this.downloadDelay);

}

});

};

this.showNotification(`开始下载 ${this.collectedUrls.length} 张图片`);

this.progressBar.style.display = 'block';

downloadNext(0);

}

updateProgressIndicator(current, total) {

const percentage = (current / total) * 100;

const progressInner = this.progressBar.firstChild;

progressInner.style.width = `${percentage}%`;

}

showNotification(message) {

const notification = document.createElement('div');

notification.textContent = message;

notification.style.cssText = `

position: fixed;

top: 10px;

right: 10px;

background: rgba(0, 0, 0, 0.7);

color: white;

padding: 10px;

border-radius: 5px;

z-index: 10001;

`;

document.body.appendChild(notification);

setTimeout(() => {

notification.style.opacity = '0';

notification.style.transition = 'opacity 0.5s';

setTimeout(() => notification.remove(), 500);

}, 3000);

}

observeImages() {

const observer = newMutationObserver((mutations) => {

mutations.forEach((mutation) => {

if (mutation.type === 'childList') {

mutation.addedNodes.forEach((node) => {

if (node.nodeType === Node.ELEMENT_NODE) {

const containers = node.querySelectorAll('.container-EdniD0');

containers.forEach(container => {

const imgElement = container.querySelector('.image-mh68Se');

const metaRightElements = container.querySelectorAll('.metaRight-fF8GZJ');

const editSection = document.querySelector('.container-RBbKMJ');

const disabledHDButton = editSection ? editSection.querySelector('.optItem-iyWnC2.disabled-R018rY') : null;

let isHD = false;

for (const metaRight of metaRightElements) {

if (metaRight.textContent.trim() === '超清') {

isHD = true;

break;

}

}

if (!isHD && disabledHDButton) {

const buttonText = disabledHDButton.textContent.trim();

if (buttonText === '超清') {

isHD = true;

}

}

if (isHD) {

let url = this.getImageUrl(imgElement);

if (url && !this.collectedUrls.includes(url)) {

this.collectedUrls.push(url);

console.log('收集新加载图片URL:', url);

this.updateCopyButtonText();

}

}

});

}

});

}

});

});

observer.observe(document.body, { childList: true, subtree: true });

}

makeDraggable(element, handle) {

let isDragging = false;

let startX, startY, startLeft, startTop;

constmovePanel = (e) => {

if (!isDragging) return;

const dx = e.clientX - startX;

const dy = e.clientY - startY;

element.style.left = `${startLeft + dx}px`;

element.style.top = `${startTop + dy}px`;

element.style.transform = 'none'; // 移除 transform 以允许自由拖动

};

conststopDragging = () => {

isDragging = false;

document.removeEventListener('mousemove', movePanel);

document.removeEventListener('mouseup', stopDragging);

};

handle.addEventListener('mousedown', (e) => {

isDragging = true;

startX = e.clientX;

startY = e.clientY;

startLeft = element.offsetLeft;

startTop = element.offsetTop;

document.addEventListener('mousemove', movePanel);

document.addEventListener('mouseup', stopDragging);

});

}

}

const collector = newImageCollector();

collector.init();

})();

三、即梦 AI 使用

使用这个工具时,要注意只收集高清的图片。所以,你需要先把确定需要的图片点击 HD,让它们变成高清模式。然后,点击已经是高清的图片,这时工具就会自动收集到下载高清图片的下载地址了。

功能介绍

第一个文本框:图片下载的前缀。你可以在这里设置一个前缀,方便你识别和管理下载的图片。第二个文本框:图片批量下载图片的起始数字。如果你已经下载了一些图片,可以从这里设置起始数字,避免重复下载。第三个文本框:每张图片下载时延时设置。这个功能可以防止因为下载速度过快而导致的网络拥堵或其他问题。

当原来下载过的图片不想继续收集,就可以点击“重新收集图片”,然后继续去点击你要的高清图片,工具就会自动记录起来,需要下载时,直接一键下载即可。

告别繁琐!用tampermonkey批量下载即梦HD图片

免费高效的 AI 编程助手,提升你的开发效率!

结合 AI 编写 Playwright 自动化发布视频代码,效率翻倍!

AI助力古诗视频制作全流程化教程

从图片到动画:AI 如何让静态玩具活起来?