OneTwitt

Скрипт заполнения данных платежной карты

May 13th, 2020
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Aliexpress CARD filler
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Заполнение данных платежной карты
  6. // @author Andronio
  7. // @match https://shoppingcart.aliexpress.ru/orders.htm?aeOrderFrom=main_shopcart*
  8. // @grant none
  9. // @noframes
  10. // ==/UserScript==
  11.  
  12. let timeout = 50;
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. var div = document.createElement('div');
  18. div.className = 'myBox';
  19.  
  20. div.innerHTML += `
  21. <input type="text" id="carddata"></br>
  22. <input type="button" id="cardfill" class="mybutton" value="Карта">
  23. `;
  24.  
  25. // Стили
  26. var styles = `
  27. .myBox {
  28. position: fixed;
  29. top: 0;
  30. right: 0;
  31. background: white;
  32. box-shadow: 1px -1px 4px 1px;
  33. max-width: 40%;
  34. max-height: 400px;
  35. padding: 10px 20px;
  36. overflow-y: auto;
  37. overflow-x: hidden;
  38. z-index:9999;
  39. }
  40.  
  41. .mybutton {
  42. display: inline;
  43. padding: 5px 10px;
  44. margin-right:auto;
  45. cursor:pointer;
  46. }`
  47.  
  48. var styleSheet = document.createElement("style")
  49. styleSheet.type = "text/css"
  50. styleSheet.innerText = styles
  51. document.head.append(styleSheet)
  52. document.body.append(div);
  53.  
  54. let mybutton1 = document.getElementById("cardfill");
  55. mybutton1.addEventListener('click', cardFunc);
  56. let mytext = document.getElementById("carddata");
  57. mytext.addEventListener('keydown', event => {
  58. if (event.keyCode == "13") {
  59. document.getElementById('cardfill').click();
  60. }
  61. });
  62. mytext.focus();
  63.  
  64. })();
  65.  
  66. function cardFunc() {
  67. let cardNumber = document.getElementById('cardNo');
  68. let cardHold = document.getElementById('cardHolder');
  69. let dateExpire = document.getElementById('expire');
  70. let codeCVC = document.getElementById('cvc');
  71. let mytext = document.getElementById("carddata");
  72. let mass;
  73.  
  74. if (mytext.value == "") return null;
  75. if (/\d{4}\s\d{4}\s\d{4}\s\d{4},\s\d{4}\/\d\d,\s\d{3},\s[\w\s]+,\s/.test(mytext.value)) {
  76. mass = mytext.value.split(', ');
  77. } else {
  78. return alert("Нет данных карты");
  79. }
  80. let nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
  81.  
  82. nativeInputValueSetter.call(cardNumber, mass[0]);
  83. cardNumber.dispatchEvent(new Event('change', {bubbles: true}));
  84. cardNumber.dispatchEvent(new Event('blur', {bubbles: true}));
  85.  
  86. nativeInputValueSetter.call(cardHold, mass[3]);
  87. cardHold.dispatchEvent(new Event('change', {bubbles: true}));
  88.  
  89. let date = mass[1].slice(5,7) + '/' + mass[1].slice(2,4);
  90. nativeInputValueSetter.call(dateExpire, date);
  91. dateExpire.dispatchEvent(new Event('change', {bubbles: true}));
  92.  
  93. nativeInputValueSetter.call(codeCVC, mass[2]);
  94. codeCVC.dispatchEvent(new Event('change', {bubbles: true}));
  95.  
  96. document.querySelector('[ae_button_type="confirm"]').click();
  97. document.querySelector(".myBox").style.display = "none";
  98. }
Add Comment
Please, Sign In to add comment