Generated Images Downloader - OPENAI DALL-E

8/25/2022, 10:23:46 AM

目前为 2022-08-26 提交的版本。查看 最新版本

// ==UserScript==
// @name        Generated Images Downloader - OPENAI DALL-E
// @namespace   Violentmonkey Scripts
// @match       https://labs.openai.com/e/*
// @grant       none
// @version     1.1.1
// @author      nopeee
// @description 8/25/2022, 10:23:46 AM
// @run-at      document-idle
// @license     MIT
// ==/UserScript==
var shouldCreateButton = true;
var shouldListenD = true;

var createButton = function() {
    let original = document.getElementsByClassName("btn btn-small btn-filled btn-secondary surprise-button")[0];
    let clone = original.cloneNode(true);
    clone.removeAttribute("id");
    clone.textContent = "Download all";
    clone.onclick = function() {
        dlGalleryImages();
    };
    document.getElementsByClassName("btn btn-small btn-filled btn-secondary surprise-button")[0].parentElement.appendChild(clone);
};

var listenD = function() {
    document.addEventListener("keydown", function(event) {
        if (event.keyCode == 68 && event.target.localName !== "input") {
            dlGalleryImages();
        }
    });
};


var isNewlyGenerated = (image) => {
    return !(image.parentElement.parentElement.className == "hist-gen-img")
};

var dlGalleryImages = () => {
    let gImages = document.getElementsByClassName("generated-image-overlay");
    for (image of gImages) {
        if (isNewlyGenerated(image)) {
            image.parentElement.parentElement.parentElement.children[1].click();
            document.getElementsByClassName("menu-item menu-item-selectable")[3].click();
        }
    }
};

var main = () => {
    if (document.getElementsByClassName("app-header-item-desktop selected")[0].text == "DALL·E") {
        if (shouldCreateButton) {
            createButton();
        }
        if (shouldListenD) {
            listenD();
        }
    }
}

setTimeout(function() {
    main();
}, 3000);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址