Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Photopea Resizer
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description try to take over the world!
- // @author You
- // @include /https?:\/\/(www\.)?photopea\.com\/?($|\?|#).*/
- // @grant none
- // ==/UserScript==
- let vColumn1Reset;
- let vColumn2Reset;
- new MutationObserver((_, observer) => {
- const input = document.querySelector('input[type="file"]');
- if (input) {
- watchInput(input);
- observer.disconnect();
- }
- }).observe(document, {childList: true, subtree: true});
- function resetColumns() {
- setTimeout(() => {
- const vColumn1 = document.querySelector('.rightbar > .vcolumn:first-child');
- const vColumn2 = document.querySelector('.rightbar > .vcolumn:nth-child(2)');
- if (vColumn1Reset === true) vColumn1.querySelector('.top').click();
- if (vColumn2Reset === true) vColumn2.querySelector('.top').click();
- vColumn1Reset = false;
- vColumn2Reset = false;
- }, 100);
- }
- function watchInput(input) {
- input.oninput = () => {
- const vColumn1 = document.querySelector('.rightbar > .vcolumn[style]:first-child');
- const vColumn2 = document.querySelector('.rightbar > .vcolumn[style]:nth-child(2)');
- if (vColumn1) {
- vColumn1Reset = true;
- vColumn1.querySelector('.top').click();
- resetColumns();
- return;
- }
- if (vColumn2) {
- vColumn2Reset = true;
- vColumn2.querySelector('.top').click()
- }
- resetColumns();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement