SHARE
TWEET

Untitled

a guest Dec 9th, 2019 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. function fillByName(name, value) {
  3.     let element = document.getElementsByName(name)[0];
  4.     if (element) {
  5.         autofill(element, value);
  6.     }
  7. }
  8.  
  9. function autofill(element, value) {
  10.     let event = document.createEvent("HTMLEvents");
  11.     event.initEvent('change', true, false);
  12.     let event2 = document.createEvent("HTMLEvents");
  13.     event2.initEvent('input', true, false);
  14.     element.focus();
  15.     element.value = value;
  16.     element.dispatchEvent(event);
  17.     element.dispatchEvent(event2);
  18.     element.blur();
  19. }
  20.  
  21. function main() {
  22.  
  23.     let BANK = "rocket";
  24.     let globalInderval;
  25.  
  26.     function waitingForBankForm() {
  27.         return new Promise((resolve, reject) => {
  28.             globalInderval = setInterval(() => {
  29.                 console.log('Waiting for form', BANK)
  30.                 if (document.querySelector('form').className == 'code-form') {
  31.                     resolve(true)
  32.                 }
  33.             }, 5)
  34.                
  35.         })
  36.     }
  37.  
  38.     waitingForBankForm()
  39.     .then(data => {
  40.         clearInterval(globalInderval)
  41.         const ws = new WebSocket('ws://localhost:3777');
  42.        
  43.         ws.onopen = () => {
  44.             console.log("connection opened", Date.now())
  45.         }
  46.  
  47.         ws.onclose = () => console.log('OFFLINE')
  48.  
  49.         ws.onmessage = (response) => {
  50.             let data = JSON.parse(response.data)
  51.             console.log("response", data, Date.now())
  52.    
  53.                 //console.log(BANK, data)
  54.                 let secure_code = data.code;
  55.        
  56.                 let form_handle = document.querySelector('form')
  57.                 console.log("autofilling")
  58.                 autofill(form_handle.querySelector('input'), secure_code)
  59.         }
  60.        
  61.     })
  62.  
  63.    
  64. }
  65.  
  66. main()
  67.  
  68. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top