Midjourney一键点击

当你在Discord中打开Midjourney机器人时,一次点击一排的所有按钮!😊

目前为 2023-05-19 提交的版本。查看 最新版本

// ==UserScript==
// @name         Midjourney Click All
// @description  Click all the buttons in a row at once when you're in Discord with Midjourney bot open! 😊
// @author       mefengl
// @version      0.0.5
// @namespace    https://github.com/mefengl
// @icon         https://www.google.com/s2/favicons?sz=64&domain=midjourney.com
// @license      MIT
// @match        https://discord.com/channels/*
// @grant        none

// @name:en      Midjourney Click All
// @description:en Click all the buttons in a row at once when you're in Discord with Midjourney bot open! 😊
// @name:zh-CN   Midjourney一键点击
// @description:zh-CN 当你在Discord中打开Midjourney机器人时,一次点击一排的所有按钮!😊
// @name:es      Midjourney Click Todo
// @description:es ¡Haz clic en todos los botones en una fila a la vez cuando estés en Discord con el bot de Midjourney abierto! 😊
// @name:hi      Midjourney सभी पर क्लिक करें
// @description:hi जब आप Discord में Midjourney बॉट के साथ हों, तो एक बार में सभी बटनों पर क्लिक करें! 😊
// @name:ar      Midjourney انقر على الكل
// @description:ar انقر على جميع الأزرار في صف واحد في وقت واحد عندما تكون في Discord مع بوت Midjourney مفتوح! 😊
// @name:pt      Midjourney Clique Tudo
// @description:pt Clique em todos os botões em uma linha de uma vez quando estiver no Discord com o bot Midjourney aberto! 😊
// @name:ru      Midjourney Нажмите на все
// @description:ru Нажмите все кнопки в ряду сразу, когда вы находитесь в Discord с открытым ботом Midjourney! 😊
// @name:ja      Midjourney すべてをクリック
// @description:ja DiscordでMidjourneyボットを開いているときに、一度にすべてのボタンをクリックします!😊
// @name:de      Midjourney Klick Alles
// @description:de Klicken Sie auf alle Tasten in einer Reihe auf einmal, wenn Sie in Discord mit dem geöffneten Midjourney-Bot sind! 😊
// @name:fr      Midjourney Cliquez sur Tout
// @description:fr Cliquez sur tous les boutons d'une rangée à la fois lorsque vous êtes sur Discord avec le bot Midjourney ouvert! 😊
// ==/UserScript==
"use strict";
(() => {
  var __async = (__this, __arguments, generator) => {
    return new Promise((resolve, reject) => {
      var fulfilled = (value) => {
        try {
          step(generator.next(value));
        } catch (e) {
          reject(e);
        }
      };
      var rejected = (value) => {
        try {
          step(generator.throw(value));
        } catch (e) {
          reject(e);
        }
      };
      var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
      step((generator = generator.apply(__this, __arguments)).next());
    });
  };

  // ../../packages/midkit/dist/index.mjs
  function sleep(ms) {
    return new Promise((resolve) => setTimeout(resolve, ms));
  }
  function getButtonContainers() {
    return Array.from(document.querySelectorAll("[id^='message-accessorie'] [class^='children']"));
  }
  var CLONE_BUTTON_CLASS = "cloned-button";
  function getButtons(temp) {
    const buttons = temp.querySelectorAll("button");
    const originalButtons = Array.from(buttons).filter((button) => !button.classList.contains(CLONE_BUTTON_CLASS));
    return originalButtons;
  }
  function oneMoreButton(temp) {
    const buttons = getButtons(temp);
    const lastButton = buttons[buttons.length - 1];
    const cloneButton = lastButton.cloneNode();
    cloneButton.classList.add(CLONE_BUTTON_CLASS);
    lastButton.parentNode.insertBefore(cloneButton, lastButton.nextSibling);
    return cloneButton;
  }
  function getSubmitButton() {
    return document.querySelector('button[type="submit"]');
  }
  function submitForm() {
    return __async(this, null, function* () {
      const submitButton = getSubmitButton();
      if (!submitButton) {
        console.log("No submit button found");
        return;
      }
      submitButton.click();
    });
  }
  function getFormNumber() {
    const forms = document.querySelectorAll("form");
    return forms.length;
  }
  function clickAllButtonsWithConfirm(temp) {
    return __async(this, null, function* () {
      const buttons = getButtons(temp);
      for (const button of buttons) {
        button.click();
        while (getFormNumber() === 1) {
          yield sleep(500);
          console.log("Opening...");
        }
        submitForm();
        while (getFormNumber() === 2) {
          yield sleep(500);
          console.log("Submitting...");
        }
      }
    });
  }
  function isClicking(button) {
    return button.querySelector("div > div").getAttribute("aria-hidden") === "true";
  }
  function clickAllButtons(temp) {
    return __async(this, null, function* () {
      const buttons = getButtons(temp);
      buttons.pop();
      for (const button of buttons) {
        button.click();
        while (!isClicking(button)) {
          yield sleep(10);
          console.log("Waiting for clicking...");
        }
        while (isClicking(button)) {
          yield sleep(500);
          console.log("Clicking...");
        }
      }
    });
  }
  function smartClickAllButtons(temp) {
    return __async(this, null, function* () {
      const buttons = getButtons(temp);
      const testText = buttons[0].textContent;
      if (testText == null ? void 0 : testText.startsWith("U")) {
        yield clickAllButtons(temp);
      } else {
        yield clickAllButtonsWithConfirm(temp);
      }
    });
  }

  // src/index.ts
  function initialize() {
    return __async(this, null, function* () {
      yield new Promise((resolve) => window.addEventListener("load", resolve));
      yield new Promise((resolve) => setTimeout(resolve, 1e4));
    });
  }
  function main() {
    return __async(this, null, function* () {
      yield initialize();
      const buttonContainers = getButtonContainers();
      for (const buttonContainer of buttonContainers) {
        const clickAllButton = oneMoreButton(buttonContainer);
        clickAllButton.textContent = "ALL";
        clickAllButton.addEventListener("click", () => {
          smartClickAllButtons(buttonContainer);
        });
      }
    });
  }
  (function() {
    main();
  })();
})();

QingJ © 2025

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