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