/* * Copyright (C) 2023 Leonid Nikitin (kor-elf) * https://git.kor-elf.net/kor-elf/service-captcha-gui/src/branch/main/LICENSE.md */ !function(e){let t=e.querySelectorAll("div.captcha-service-kor-elf");function n(e){e.style.display="none"}function c(t,n,c,a){let i=t.querySelector("div.window-captcha__content__body");if(i.querySelectorAll(".loading").length>0)return null;i.innerHTML='
',fetch(n+"/api/v1/captcha",{headers:{"Content-Type":"application/json",Accept:"application/json","public-token":c}}).then(e=>e.json()).then(function(t){let r=t.image_body.width,l=t.image_body.height;i.innerHTML=``;let d=i.querySelector("div.window-captcha__content__body__coordinator"),s=d.querySelector("img");s.addEventListener("click",function(t){let n=e.createElement("div");n.style.left=t.offsetX/s.width*100+"%",n.style.top=t.offsetY/s.height*100+"%",n.classList.add("pointer");let c=t.offsetX*(r/s.width),o=t.offsetY*(l/s.height),a=d.querySelectorAll(".pointer").length+1;n.innerHTML=`${a}`,n.addEventListener("click",function(){n.remove(),d.querySelectorAll(".pointer").forEach(function(e,t){e.querySelector("span.pounter__number").textContent=t+1})}),d.appendChild(n)}),i.querySelector(".window-captcha__content__body__button").addEventListener("click",function(){(function t(n,c,a,i){let r=n.querySelector("button.window-captcha__content__body__button");if(r.querySelectorAll(".loading").length>0)return null;let l=e.createElement("span");l.classList.add("loading"),r.appendChild(l);let d={captcha_key:n.querySelector(".captcha_key").value,verification:[]};n.querySelectorAll(".pointer").forEach(function(e){d.verification.push({x:e.querySelector(".x").value,y:e.querySelector(".y").value})}),fetch(c+"/api/v1/captcha",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","public-token":a},body:JSON.stringify(d)}).then(e=>{if(429===e.status){o("Вы превысили количество попыток. Обновите каптчу.",r);return}return e.json()}).then(function(t){if(void 0!==t.errors){let n="";for(let c in t.errors)n+=t.errors[c]+"