Advertisement
Guest User

Designer Endless Generation

a guest
Mar 3rd, 2024
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         EndlessGeneration
  3. // @namespace    http://tampermonkey.net/
  4. // @version      v1
  5. // @description  Автоматически бесконечно нажимает на кнопку «Генерировать».
  6. // @author       anon
  7. // @match        https://designer.microsoft.com/image-creator*
  8. // @icon         https://store-images.s-microsoft.com/image/apps.59810.14282385397322807.c2ae4608-6889-4e10-816d-7f8254d76cad.c6b7e4a4-1f74-4c8f-8639-28fef3c09030
  9. // @grant        none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. var startButton;
  15. var stopButton;
  16. var genButton;
  17.  
  18. const buttonChecker = new MutationObserver(function()
  19. {
  20.     var buttons = document.getElementsByTagName("button");
  21.     for (var button of buttons)
  22.     {
  23.         if (button.innerText == "Generate")
  24.         {
  25.             genButton = button;
  26.             buttonChecker.disconnect();
  27.             addExternalButtons();
  28.         }
  29.     }
  30. });
  31. buttonChecker.observe(document, {childList: true, subtree: true});
  32.  
  33. const mainChecker = new MutationObserver(function()
  34. {
  35.     if (!genButton.disabled){genButton.click();}
  36. });
  37.  
  38. function addExternalButtons()
  39. {
  40.     startButton = document.getElementById("startButton");
  41.     if (!startButton)
  42.     {
  43.         startButton = document.createElement("button");
  44.         startButton.id = "startButton";
  45.         startButton.innerText = "Генерировать!";
  46.         startButton.onclick = startMainObserver;
  47.         startButton.style.borderRadius = "12px";
  48.         startButton.style.margin = "5px";
  49.         startButton.style.borderStyle = "solid";
  50.         startButton.style.borderWidth = "5px";
  51.         genButton.form.prepend(startButton);
  52.     }
  53.     stopButton = document.getElementById("stopButton");
  54.     if (!stopButton)
  55.     {
  56.         stopButton = document.createElement("button");
  57.         stopButton.id = "stopButton";
  58.         stopButton.innerText = "Не генерировать!";
  59.         stopButton.onclick = stopMainObserver;
  60.         stopButton.style.borderRadius = "12px";
  61.         stopButton.style.margin = "5px";
  62.         stopButton.style.borderStyle = "solid";
  63.         stopButton.style.borderWidth = "5px";
  64.         genButton.form.prepend(stopButton);
  65.         document.getElementById("stopButton").disabled = true;
  66.     }
  67. }
  68.  
  69. function startMainObserver()
  70. {
  71.     mainChecker.observe(genButton, {attributes: true});
  72.     startButton.disabled = true;
  73.     stopButton.disabled = false;
  74.     genButton.click();
  75. }
  76.  
  77. function stopMainObserver()
  78. {
  79.     mainChecker.disconnect();
  80.     startButton.disabled = false;
  81.     stopButton.disabled = true;
  82. }
  83. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement