Advertisement
YOLOdanverga

demo type racing automatic type

Jun 1st, 2025
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.68 KB | Source Code | 0 0
  1. (function() {
  2.   const spans = document.querySelectorAll('span[unselectable="on"]');
  3.   const input = document.querySelector('input.txtInput');
  4.  
  5.   if (spans.length > 0 && input) {
  6.     let text = '';
  7.     spans.forEach(span => {
  8.       text += span.textContent;
  9.     });
  10.  
  11.     input.focus();
  12.     input.value = "";  
  13.  
  14.     let index = 0;
  15.  
  16.     function typeNextChar() {
  17.       if (index < text.length) {
  18.         input.value += text.charAt(index);
  19.         input.dispatchEvent(new Event('input', { bubbles: true }));
  20.         index++;
  21.         setTimeout(typeNextChar, 100);
  22.       }
  23.     }
  24.  
  25.     typeNextChar();
  26.   } else {
  27.     console.warn("Spans or input not found.");
  28.   }
  29. })();
  30.  
Tags: typeracer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement