Greasy Fork

Greasy Fork is available in English.

Generated Images Downloader - OPENAI DALL-E

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Generated Images Downloader - OPENAI DALL-E
// @namespace   Violentmonkey Scripts
// @match       https://labs.openai.com/e/*
// @grant       none
// @version     1.1.3.5
// @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.insertBefore(clone,document.getElementsByClassName("btn btn-small btn-filled btn-secondary surprise-button")[0].parentElement.firstElementChild)};

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 = (cb,ld) => {
    if (document.getElementsByClassName("app-header-item-desktop selected")[0].text == "DALL·E") {
        if (cb) {
            createButton();
        }
        if (ld) {
            listenD();
        }
      let test = [...document.getElementsByClassName("hist-task mt-6")] 
      test.forEach((batch) => {
  batch.onclick = function() {
    
    setTimeout(function() {main(true,false)},2000)
  }
}) 
    }
}

setTimeout(function() {
    main(shouldCreateButton,shouldListenD);
}, 2000);