Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name EndlessGeneration
- // @namespace http://tampermonkey.net/
- // @version v1
- // @description Автоматически бесконечно нажимает на кнопку «Генерировать».
- // @author anon
- // @match https://designer.microsoft.com/image-creator*
- // @icon https://store-images.s-microsoft.com/image/apps.59810.14282385397322807.c2ae4608-6889-4e10-816d-7f8254d76cad.c6b7e4a4-1f74-4c8f-8639-28fef3c09030
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- var startButton;
- var stopButton;
- var genButton;
- const buttonChecker = new MutationObserver(function()
- {
- var buttons = document.getElementsByTagName("button");
- for (var button of buttons)
- {
- if (button.innerText == "Generate")
- {
- genButton = button;
- buttonChecker.disconnect();
- addExternalButtons();
- }
- }
- });
- buttonChecker.observe(document, {childList: true, subtree: true});
- const mainChecker = new MutationObserver(function()
- {
- if (!genButton.disabled){genButton.click();}
- });
- function addExternalButtons()
- {
- startButton = document.getElementById("startButton");
- if (!startButton)
- {
- startButton = document.createElement("button");
- startButton.id = "startButton";
- startButton.innerText = "Генерировать!";
- startButton.onclick = startMainObserver;
- startButton.style.borderRadius = "12px";
- startButton.style.margin = "5px";
- startButton.style.borderStyle = "solid";
- startButton.style.borderWidth = "5px";
- genButton.form.prepend(startButton);
- }
- stopButton = document.getElementById("stopButton");
- if (!stopButton)
- {
- stopButton = document.createElement("button");
- stopButton.id = "stopButton";
- stopButton.innerText = "Не генерировать!";
- stopButton.onclick = stopMainObserver;
- stopButton.style.borderRadius = "12px";
- stopButton.style.margin = "5px";
- stopButton.style.borderStyle = "solid";
- stopButton.style.borderWidth = "5px";
- genButton.form.prepend(stopButton);
- document.getElementById("stopButton").disabled = true;
- }
- }
- function startMainObserver()
- {
- mainChecker.observe(genButton, {attributes: true});
- startButton.disabled = true;
- stopButton.disabled = false;
- genButton.click();
- }
- function stopMainObserver()
- {
- mainChecker.disconnect();
- startButton.disabled = false;
- stopButton.disabled = true;
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement