Universal Maxlength Expander

Sets all maxlength values to 999999 across all websites

  1. // ==UserScript==
  2. // @name Universal Maxlength Expander
  3. // @namespace https://www.youtube.com/@joshclark756
  4. // @author joshclark756
  5. // @version 1.0
  6. // @description Sets all maxlength values to 999999 across all websites
  7. // @match *://*/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function expandMaxlength() {
  16. const inputs = document.querySelectorAll('input[maxlength], textarea[maxlength]');
  17. inputs.forEach(input => {
  18. input.setAttribute('maxlength', '999999');
  19. });
  20. }
  21.  
  22. // Run on page load
  23. expandMaxlength();
  24.  
  25. // Set up a MutationObserver to handle dynamically added elements
  26. const observer = new MutationObserver((mutations) => {
  27. mutations.forEach((mutation) => {
  28. if (mutation.type === 'childList') {
  29. expandMaxlength();
  30. }
  31. });
  32. });
  33.  
  34. // Start observing the document with the configured parameters
  35. observer.observe(document.body, { childList: true, subtree: true });
  36. })();