// ==UserScript==
// @name AliCap
// @namespace http://tampermonkey.net/
// @version 0.2
// @description try to take over the world!
// @author future_
// @match https://*.aliexpress.com/*
// @match https://*.aliexpress.ru/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
if(document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded',add);
} else {
add(); add2();
}
function add(){
document.body.insertAdjacentHTML('beforeend', '<div id="cont1" style="padding:5px;width:13%;height:58%;top:15%;left:5px;position:fixed;backdrop-filter: blur(2px);border-radius:8px;border:1px solid #e6e6e680;display:flex;flex-direction: column;background:#e6e6e680;color:white;z-index:9999999;display:none;"></div>');
var main = document.getElementById('cont1');
var cap =[
'5ufh','7fkt','9gnn','bwsj','dbpr','efu2','mrrp','rcvc','usn8','uh9g'
]
for(var i=0;i<10;i++){
var curr=i+1;
var str=cap[i]
main.insertAdjacentHTML('beforeend', '<div id="c'+curr+'" style="cursor:pointer;background:#0099dd;text-align:center;border:0px solid transparent;border-radius:1px;color:white;width:100%;height:9%;padding:3px;margin-bottom:5px;">'+str+'</div>');
document.getElementById('c'+curr).addEventListener('click',enter)
}
document.body.appendChild( document.getElementById('cont1'));
}//add
function add2(){
document.body.insertAdjacentHTML('beforeEnd', '<div id="cont2" style="padding:5px;width:13%;height:90x;top:10%;left:5px;position:fixed;backdrop-filter: blur(2px);border-radius:8px;border:1px solid #e6e6e680;background:#e6e6e680;color:white;z-index:9999998;display:block;"></div>');
var sec = document.getElementById('cont2');
var but = 'слайдер'
sec.insertAdjacentHTML('beforeEnd', '<div id="but" style="cursor:pointer;background:#007ab1;text-align:center;border:0px solid transparent;border-radius:1px;color:white;width:100%;height:100%;padding:3px;margin-bottom:5px;">'+but+'</div>');
document.getElementById('but').addEventListener('click',curtail)
document.getElementById('but').addEventListener('click',slid)
document.body.appendChild( document.getElementById('cont2'));
}//add
function enter(){
console.log(event.target);
var c_form;
for(var j=1;j<11;j++){
c_form = document.getElementById('nc_'+j+'_captcha_input');
if(!c_form){ continue;}else{break;}
}
var nivs = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
nivs.call(c_form, event.target.innerText);
}
function curtail(){
document.getElementById('cont1').style.display='block'; // покажет капчу
}
async function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
};
function sendMouseEvent(x, y, element, eventType) {
let evObj = document.createEvent('MouseEvents');
evObj.initMouseEvent( eventType, true, true, window, 1, x, y, x, y, false, false, false, false, 0, null );
element.dispatchEvent(evObj);
}
async function slid(){
let slider = document.getElementById('nc_1_n1z');
let coord = slider.getBoundingClientRect();
let field = document.getElementById('nc_1__scale_text');
let fieldWidth = field.getBoundingClientRect();
sendMouseEvent(coord.x + coord.height / 2, coord.y + coord.width / 2, slider, 'mousedown');
await sleep(200);
sendMouseEvent(coord.x + coord.height + fieldWidth.width, coord.y + coord.width / 2, slider, 'mousemove');
await sleep(500);
}
})();