OneTwitt

Скрипт автозаполнения профиля для смены страны

May 13th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Aliexpress profile filler for Game
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Изменяет страну на USA и заполняет поля
  6. // @author Andronio
  7. // @match https://accounts.aliexpress.com/user/organization/manage_person_profile.htm?isEdit=true
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. var myCountry = "KZ";
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Your code here...
  17. var div = document.createElement('div');
  18. div.className = 'mybox';
  19.  
  20. div.innerHTML += `
  21. <input type="button" id="usa" class="mybutton" value="Fill USA">
  22. <input type="button" id="kaz" class="mybutton" value="Fill ${myCountry}">
  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: 10px 20px;
  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.appendChild(styleSheet)
  52. document.body.appendChild(div);
  53. let mybutton1 = document.getElementById("usa");
  54. mybutton1.addEventListener('click', fillUSA);
  55. let mybutton2 = document.getElementById("kaz");
  56. mybutton2.addEventListener('click', fillKAZ);
  57. })();
  58.  
  59. async function fillUSA() {
  60. let genderMale = document.getElementById("mr");
  61. let genderFemale = document.getElementById("ms");
  62. let countrySel = document.getElementById("countrySelect");
  63. let allInput = document.querySelectorAll("input");
  64. let submitButton = document.getElementById("formSubmit");
  65.  
  66. if (genderMale.checked == false && genderFemale.checked == false) {
  67. if (Math.random() > 0.5) {
  68. genderMale.checked = true;
  69. } else {
  70. genderFemale.checked = true;
  71. }
  72. }
  73.  
  74. if (allInput[10].value == "") allInput[10].value = randomString(9);
  75. if (allInput[11].value == "") allInput[11].value = randomString(9);
  76.  
  77. countrySel.value = "US";
  78. countrySel.onchange();
  79. await sleep(500);
  80. let province = document.getElementById("usProvinceList");
  81. province.selectedIndex = Math.floor(Math.random() * province.length);
  82.  
  83. if (allInput[13].value == "") allInput[13].value = getRandomInt(999999);
  84.  
  85. allInput[14].value = "1";
  86. allInput[15].value = getRandomInt(999);
  87. allInput[16].value = getRandomInt(99999999);
  88. allInput[17].value = "1";
  89. submitButton.click();
  90. }
  91.  
  92. async function fillKAZ() {
  93. let genderMale = document.getElementById("mr");
  94. let genderFemale = document.getElementById("ms");
  95. let countrySel = document.getElementById("countrySelect");
  96. let allInput = document.querySelectorAll("input");
  97. let submitButton = document.getElementById("formSubmit");
  98.  
  99. if (genderMale.checked == false && genderFemale.checked == false) {
  100. if (Math.random() > 0.5) {
  101. genderMale.checked = true;
  102. } else {
  103. genderFemale.checked = true;
  104. }
  105. }
  106.  
  107. if (allInput[10].value == "") allInput[10].value = randomString(9);
  108. if (allInput[11].value == "") allInput[11].value = randomString(9);
  109.  
  110. countrySel.value = myCountry;
  111. countrySel.onchange();
  112. await sleep(500);
  113.  
  114. allInput[12].value = randomString(9);
  115.  
  116. allInput[13].value = getRandomInt(999999);
  117.  
  118. allInput[14].value = "7";
  119. allInput[15].value = getRandomInt(999);
  120. allInput[16].value = getRandomInt(99999999);
  121. allInput[17].value = "7";
  122. submitButton.click();
  123.  
  124. }
  125.  
  126. function randomString(i)
  127. {
  128. var text = "";
  129. var possible = "abcdefghijklmnopqrstuvwxyz";
  130.  
  131. while (text.length < i)
  132. text += possible.charAt(Math.floor(Math.random() * possible.length));
  133.  
  134. return text;
  135. }
  136.  
  137. function sleep(ms) {
  138. return new Promise(resolve => setTimeout(resolve, ms));
  139. }
  140.  
  141. function getRandomInt(max) {
  142. return Math.floor(Math.random() * Math.floor(max)).toString();
  143. }
Add Comment
Please, Sign In to add comment