Modify Text Area from pixai prompts

Modifica el tamaño de un área de texto y agrega un botón para alternar el tamaño uwu

  1. // ==UserScript==
  2. // @name Modify Text Area from pixai prompts
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3
  5. // @description Modifica el tamaño de un área de texto y agrega un botón para alternar el tamaño uwu
  6. // @author Abejita
  7. // @match https://pixai.art/generator/image
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Función para crear el botón
  16. function createButton() {
  17. let buttonContainer = document.querySelector('.px-4.py-1.flex.gap-4.items-center .flex-1');
  18. if (buttonContainer && !document.querySelector('#toggleSizeButton')) {
  19. let button = document.createElement('button');
  20. button.id = 'toggleSizeButton';
  21. button.textContent = 'Agrandar';
  22. button.style.padding = '8px 18px';
  23. button.style.borderRadius = '5px';
  24. button.style.border = 'none';
  25. button.style.background = 'linear-gradient(to right, #ff7ec5, #c36bfb)';
  26. button.style.color = 'white';
  27. button.style.cursor = 'pointer';
  28. button.style.fontSize = '16px';
  29. button.style.margin = '10px';
  30. buttonContainer.appendChild(button);
  31.  
  32. button.addEventListener('click', toggleSize);
  33. }
  34. }
  35.  
  36. // Función para alternar el tamaño del área de texto
  37. function toggleSize() {
  38. let elements = document.querySelectorAll('textarea.w-full.min-h-\\[3em\\].max-h-\\[9em\\].dense\\:max-h-\\[5em\\].bg-transparent.outline-none.resize-none');
  39. elements.forEach(element => {
  40. if (element.style.height === '400px') {
  41. element.style.height = '120px';
  42. element.style.maxHeight = '2000px';//9em
  43. document.querySelector('#toggleSizeButton').textContent = 'Agrandar';
  44. } else {
  45. element.style.height = '400px';
  46. element.style.maxHeight = '2000px';
  47. document.querySelector('#toggleSizeButton').textContent = 'Reducir';
  48. }
  49. });
  50. }
  51.  
  52. // Crear el botón al cargar la página completamente
  53. window.addEventListener('load', function() {
  54. setTimeout(createButton, 6000);
  55. });
  56.  
  57. // Crear el botón al presionar F9
  58. document.addEventListener('keydown', function(event) {
  59. if (event.key === 'F9') {
  60. createButton();
  61. }
  62. });
  63.  
  64. // Revisa cada 6 segundos para asegurarse de que el botón aparezca correctamente
  65. setInterval(createButton, 6000);
  66. })();