// ==UserScript==
// @name Alipay CARD filler
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author Andronio
// @match https://intl.alipay.com/bindcard/selfaddcard.htm
// @match https://intl.alipay.com/user/activateEmail.htm
// @grant none
// @run-at document-idle
// ==/UserScript==
(function() {
'use strict';
let cardType = 1; // 0 - visa, 1 - mastercard
let cardNumber = '0000 0000 0000 0000';
let cardMonth = '09'; // месяц
let cardYear = '21'; // год
let code = '123'; // код CCV
let country = 'KZ'; // страна, ни на что не влияет
let delay = 1000; // задержка перед нажатием "сохранить карту"
if (location.href == "https://intl.alipay.com/user/activateEmail.htm") {
setTimeout(function(){
let captchaElem = document.getElementById('AT-refresh-img');
if (captchaElem) location.href = "https://intl.alipay.com/bindcard/selfaddcard.htm";
}, 500);
} else {
let cardTypeElem = document.querySelectorAll('#j-card-types input');
let cardNumberElem = document.getElementById('j-card-number');
let cardMonthElem = document.querySelector('input[name="expiryMonth"]');
let cardYearElem = document.querySelector('input[name="expiryYear"]');
let codeElem = document.querySelector('input[name="cvv2"]');
// CARD Type
cardTypeElem[cardType].click();
let countryElem = document.getElementById('country');
countryElem.value = country;
countryElem.dispatchEvent(new Event('change', {bubbles: true}));
countryElem.dispatchEvent(new Event('keyup', {bubbles: true}));
countryElem.dispatchEvent(new Event('keydown', {bubbles: true}));
countryElem.dispatchEvent(new Event('keypress', {bubbles: true}));
countryElem.dispatchEvent(new Event('input', {bubbles: true}));
countryElem.dispatchEvent(new Event('blur', {bubbles: true}));
setInput(cardNumberElem, cardNumber);
setInput(cardMonthElem, cardMonth);
setInput(cardYearElem, cardYear);
setInput(codeElem, code);
setInput(document.querySelector('input[name="firstName"]'), randomString(10));
setInput(document.querySelector('input[name="lastName"]'), randomString(10));
setInput(document.getElementById('address1'), randomString(10));
setInput(document.getElementById('city'), randomString(10));
setInput(document.getElementById('state'), randomString(10));
setInput(document.getElementById('postCode'), randomInt(6));
setTimeout(() => document.querySelector('button').click(), delay);
function setInput(input, value) {
if (!input) {
return;
}
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
nativeInputValueSetter.call(input, value);
input.dispatchEvent(new Event('change', {bubbles: true}));
input.dispatchEvent(new Event('keyup', {bubbles: true}));
input.dispatchEvent(new Event('keydown', {bubbles: true}));
input.dispatchEvent(new Event('keypress', {bubbles: true}));
input.dispatchEvent(new Event('input', {bubbles: true}));
input.dispatchEvent(new Event('blur', {bubbles: true}));
};
function randomString(i) {
var text = "";
var possible = "abcdefghijklmnopqrstuvwxyz";
while (text.length < i)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
function randomInt(i) {
var text = "";
var possible = "0123456789";
while (text.length < i)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
}
})();