Advertisement
Nom1fan

Auto Fill Field

Feb 8th, 2019 (edited)
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Fill in Arnona form 1/4
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       You
  7. // @match        https://city4u.co.il/PortalServicesSite/cityPay/264000/mislaka/1
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. //CcNumber
  12. (function() {
  13.     'use strict';
  14.     fillInField("MisparHeshbon", "xxxxxx");
  15.     fillInField("txtPhone", "xxxxxx");
  16.     fillInField("txtEmail", "xxxx@gmail.com");
  17.     fillInField("txtFullName", "xxxxx");
  18.     fillInField("CcNumber", "xxxxxxx");
  19.     fillInField("ccOwnerId", "xxxxx");
  20.     fillInField("CcValidationCode", "029");
  21.     var yearFieldName = "שנה";
  22.     fillInComboBox(yearFieldName, "0", 0);
  23.     var monthFieldName = "חודש";
  24.     fillInComboBox(monthFieldName, "4", 1);
  25. })();
  26.  
  27. function fillInField(fieldName, value) {
  28.     (function() {
  29.         var checkExist = setInterval(function() {
  30.             var fieldObj = document.getElementById(fieldName);
  31.             if (fieldObj != null) {
  32.                 console.log(fieldName + " exists!");
  33.                 fieldObj.value = value;
  34.                 clearInterval(checkExist);
  35.             }
  36.         }, 100); // check every 100ms
  37.     })();
  38. }
  39.  
  40. function fillInComboBox(fieldName, value, index) {
  41.     (function() {
  42.         var checkExist = setInterval(function() {
  43.             var selectField = document.getElementsByClassName("select-cc-date")[index];
  44.             var isField = selectField.innerHTML.includes(fieldName);
  45.             if (isField) {
  46.                 console.log(fieldName + " exists!");
  47.                 selectField.value = value;
  48.                 clearInterval(checkExist);
  49.             }
  50.         }, 100); // check every 100ms
  51.     })();
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement