// ==UserScript==
// @name Aliexpress Register/Login
// @namespace http://tampermonkey.net/
// @version 0.2
// @description try to take over the world!
// @author Andronio
// @match https://login.aliexpress.com/*
// @match https://login.aliexpress.ru/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var div = document.createElement('div');
div.className = 'myBox';
div.innerHTML += `
<input type="text" id="namepass"></br>
<input type="button" id="rega" class="mybutton" value="Рега">
<input type="button" id="vhod" class="mybutton" value="Вход">
`;
// Стили
var styles = `
.myBox {
position: fixed;
top: 0;
right: 0;
background: white;
box-shadow: 1px -1px 4px 1px;
max-width: 40%;
max-height: 400px;
padding: 10px 20px;
overflow-y: auto;
overflow-x: hidden;
z-index:9999;
}
.mybutton {
display: inline;
padding: 5px 10px;
margin-right:auto;
cursor:pointer;
}`
var styleSheet = document.createElement("style")
styleSheet.type = "text/css"
styleSheet.innerText = styles
document.head.append(styleSheet)
document.body.append(div);
let mybutton1 = document.getElementById("rega");
let mybutton2 = document.getElementById("vhod");
mybutton1.addEventListener('click', regaFunc);
mybutton2.addEventListener('click', vhodFunc);
let mytext = document.getElementById("namepass");
mytext.addEventListener('keydown', event => {
if (event.keyCode == "13") {
if (event.code == "Enter" && !event.shiftKey) document.getElementById('vhod').click();
if (event.code == "NumpadEnter" || event.code == "Enter" && event.shiftKey) document.getElementById('rega').click();
}
});
mytext.focus();
})();
// Функция регистрации
function regaFunc () {
let namepass = document.getElementById("namepass");
let mass;
mass = parseString(namepass.value);
if (mass) {
document.querySelectorAll(".next-tabs-tab")[0].click();
let email = document.querySelector(".email");
let pass = document.querySelector(".password");
email.setAttribute("value", mass[0]);
email.dispatchEvent(new Event("change", {bubbles: true}));
email.dispatchEvent(new Event("blur", {bubbles: true}));
let nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
nativeInputValueSetter.call(pass, mass[1]);
pass.dispatchEvent(new Event('change', {bubbles: true}));
pass.dispatchEvent(new Event('blur', {bubbles: true}));
setTimeout(waitReady, 200);
} else alert("Нет логина");
}
// Ждем проверки email при реге
let timeout = 50;
function waitReady() {
if (document.querySelector(".email-checking")) {
if (--timeout) return setTimeout(waitReady, 200);
else return;
}
document.querySelector(".submit").click();
}
// Функция входа
function vhodFunc () {
let namepass = document.getElementById("namepass");
let mass;
mass = parseString(namepass.value);
if (mass) {
document.querySelectorAll(".next-tabs-tab")[1].click();
let signName = document.getElementById("fm-login-id");
let signPass = document.getElementById("fm-login-password");
let enterButton = document.querySelector(".fm-button.fm-submit.password-login");
signPass.value = mass[1];
signName.value = mass[0];
enterButton.click();
} else alert("Нет логина");
}
function parseString(str) {
if (str == "") return null;
if (/\w+@[\w\.]+\.\w+\t\w+/.test(str)) {
return str.split('\t');
} else if (/\w+@[\w\.]+\.\w+:\w+/.test(str)) {
return str.split(':');
} else return null;
}