Guest User

8ch checkbox and input field preference thing 2.0

a guest
Apr 18th, 2025
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function enforce8chanForm() {
  2.     function simulateClick(el) {
  3.         ['mousedown','mouseup','click'].forEach(type =>
  4.             el.dispatchEvent(new MouseEvent(type, { bubbles: true, cancelable: true }))
  5.         );
  6.         el.dispatchEvent(new Event('change', { bubbles: true }));
  7.     }
  8.  
  9.     ['qrcheckboxNoFlag','qrcheckboxScramble'].forEach(id => {
  10.         const cb = document.getElementById(id);
  11.         if (cb && cb.type === 'checkbox' && !cb.checked) {
  12.             simulateClick(cb);
  13.         }
  14.     });
  15.  
  16.     ['qrname','qrsubject','qremail','qrpassword'].forEach(id => {
  17.         const el = document.getElementById(id);
  18.         if (el && el.tagName === 'INPUT') {
  19.             el.focus();
  20.             el.value = '';
  21.             el.dispatchEvent(new Event('input', { bubbles: true }));
  22.             el.dispatchEvent(new Event('change', { bubbles: true }));
  23.             el.blur();
  24.         }
  25.     });
  26. }
  27. window.addEventListener('load', enforce8chanForm);
Advertisement
Add Comment
Please, Sign In to add comment