Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Designer AI Slop
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description Auto Slop
- // @author (You)
- // @match https://designer.microsoft.com/image-creator*
- // @run-at document-end
- // @grant GM_download
- // @grant GM_addStyle
- // ==/UserScript==
- // --------------------------------
- // if yellow warning = will try again after 5s
- // if red warning = will try again after 45s
- // ON/OFF = enable/disable autoclick
- // turn it off first if you are testing words/prompts, so it won't autoclick if you get a bad word warning
- // tested with Tampermonkey
- var audio = new Audio('https://website.com/ding.mp3'); //put a url to a mp3 that you want to play when an image is generated. or leave empty ''
- audio.volume = 1.0; // 0.0 to 1.0
- // --------------------------------
- function playAudio() { //may not work with browsers with anti-autoplay rules
- audio.play();
- };
- let timeoutId1 = null
- let timeoutId2 = null
- function createToggleButton() {
- let textarea = document.querySelector('.fui-Button.ri7kuyr');
- if (textarea) {
- let toggle = document.createElement('div');
- toggle.className = 'toggleButton';
- let isOn = localStorage.getItem('toggleState') === 'ON' ? true : false;
- toggle.innerText = isOn ? 'ON' : 'OFF';
- toggle.style.backgroundColor = isOn ? 'green' : 'red';
- toggle.addEventListener('click', function() {
- isOn = !isOn;
- toggle.innerText = isOn ? 'ON' : 'OFF';
- toggle.style.backgroundColor = isOn ? 'green' : 'red';
- localStorage.setItem('toggleState', isOn ? 'ON' : 'OFF');
- if (!isOn) {
- clearTimeout(timeoutId1);
- timeoutId1 = null
- clearTimeout(timeoutId2);
- timeoutId2 = null
- document.title = "Image Creator";
- }
- });
- toggle.style.display = 'block';
- toggle.style.marginLeft = 'auto';
- toggle.style.marginRight = 'auto';
- textarea.parentNode.insertBefore(toggle, textarea.nextSibling);
- return true;
- }
- return false;
- }
- let intervalId = setInterval(function() {
- if (createToggleButton()) {
- clearInterval(intervalId);
- }
- }, 2000);
- GM_addStyle(`
- .toggleButton {
- border: none;
- color: white;
- padding: 02px 20px;
- text-align: center;
- text-decoration: none;
- display: inline-block;
- font-size: 16px;
- margin: 4px 2px;
- cursor: pointer;
- }
- `);
- function addDownloadButtons() {
- let grid = document.querySelector('[data-testid^="media-asset-button"]');
- if (!grid) { return }
- let buttons = document.querySelectorAll('[data-testid^="media-asset-button"]');
- if (buttons[0].nextSibling && buttons[0].nextSibling.tagName === 'BUTTON') { return true; }
- if (grid) { grid.click(); }
- let divs = document.querySelectorAll('.fui-FluentProvider.fui-FluentProvider1.___1bsm0mz');
- if (divs.length >= 2) {
- divs[1].style.display = 'none';
- }
- let images;
- if (buttons.length === 1) {
- images = document.querySelectorAll('.___1h0r9zi.f22iagw');
- } else {
- images = document.querySelectorAll('[data-testid^="media-asset-modal-item-"]');
- }
- let firstUrl = images[0].firstChild.src;
- let storedUrl = localStorage.getItem('firstUrl');
- if (storedUrl !== firstUrl) {
- localStorage.setItem('firstUrl', firstUrl);
- playAudio();
- document.title = "Done!";
- }
- let element = document.querySelector('[data-testid="media-asset-modal-close-btn"]');
- if (element) { element.click(); }
- for (let i = 0; i < buttons.length; i++) {
- if (images[i]) {
- let img = images[i].firstChild;
- let dataUrl = img.src;
- let newButton = document.createElement('button');
- newButton.innerText = 'Download Image ' + (i + 1);
- newButton.style.display = 'block';
- newButton.style.margin = 'auto';
- newButton.style.marginTop = '10px';
- newButton.addEventListener('click', function() {
- let date = new Date();
- let year = date.getFullYear();
- let month = (date.getMonth() + 1).toString().padStart(2, '0');
- let day = date.getDate().toString().padStart(2, '0');
- let hours = date.getHours().toString().padStart(2, '0');
- let minutes = date.getMinutes().toString().padStart(2, '0');
- let seconds = date.getSeconds().toString().padStart(2, '0');
- let dateTime = year + '-' + month + '-' + day + ' ' + hours + '_' + minutes + '_' + seconds;
- let downloadOptions = {
- url: dataUrl,
- name: 'Designer - ' + dateTime + '.jpg'
- };
- GM_download(downloadOptions);
- });
- buttons[i].parentNode.insertBefore(newButton, buttons[i].nextSibling);
- }
- }
- return false;
- }
- function CheckAndClickButton() {
- let toggleState = localStorage.getItem('toggleState');
- if (toggleState === 'OFF') {
- return;
- }
- let warning1 = document.querySelector('.___ogrvaz0.f5ogflp.f1hqa2wf.f1f09k3d'); //yellow warning
- let warning2 = document.querySelector('.___1fkmo9w.f5ogflp.f1hqa2wf.f1f09k3d'); //red warning
- let button = document.querySelector('.fui-Button.ri7kuyr.___vnqwgp0.ffp7eso.f1p3nwhy');
- if (button) {
- if (warning1 && !timeoutId1) {
- document.title = "Working...";
- timeoutId1 = setTimeout(function() {
- button.click();
- timeoutId1 = null;
- }, 5000); // Wait for 5 seconds to click
- }
- if (warning2 && !timeoutId2) {
- document.title = "Working...";
- timeoutId2 = setTimeout(function() {
- button.click();
- timeoutId2 = null;
- }, 45000); // Wait for 45 seconds to click
- }
- }
- }
- setInterval(function() {
- let button = document.querySelector('.fui-Button.ri7kuyr.___vnqwgp0.ffp7eso.f1p3nwhy');
- if (button) {
- addDownloadButtons();
- if (!button.disabled) {
- CheckAndClickButton();
- }
- }
- }, 2000); // Check page every 2 seconds
Advertisement
Add Comment
Please, Sign In to add comment