netsyms-captcheck/captcheck.dist.js

1 line
4.8 KiB
JavaScript

window.onload=function(){var e="https://captcheck.netsyms.com/api.php";function t(e,t){return document.getElementById("captcheck_"+e+"_answer_"+t).checked=!0,!1}function a(e){var t=document.getElementById("captcheck_"+e+"_alt_question_button"),a=document.getElementById("captcheck_"+e+"_question_image"),n=document.getElementById("captcheck_"+e+"_question_access"),c=document.getElementById("captcheck_"+e+"_answer_images"),i=document.getElementById("captcheck_"+e+"_answer_access");"&gt; Text mode"==t.innerHTML?(t.innerHTML="&gt; Image mode",a.style.display="none",n.style.display="initial",c.style.display="none",i.style.display="initial",i.innerHTML="<input type='text' name='captcheck_selected_answer' aria-label='Type your answer here.' autocomplete='off' autofill='off'/>"):(t.innerHTML="&gt; Text mode",a.style.display="initial",n.style.display="none",c.style.display="initial",i.style.display="none",i.innerHTML="")}var n="";Array.prototype.forEach.call(document.getElementsByClassName("captcheck_container"),function(c){c.dataset.stylenonce&&(n=c.dataset.stylenonce);var i=new XMLHttpRequest;i.open("GET",e+"?action=new",!0),i.onreadystatechange=function(){if(4==this.readyState){var n=this.status,i=this.responseText,s=document.createElement("div");if(s.setAttribute("class","captcheck_box"),c.appendChild(s),200==n){for(var r=JSON.parse(i),o=r.id_prefix,d="<div class='captcheck_answer_images' id='captcheck_"+o+"_answer_images'>",l=0,p=r.answers.length;l<p;l++){var _=e+"?action=img&s="+r.session+"&c="+r.answers[l];d+="<a class='captcheck_answer_label' href='' data-prefix='"+o+"' data-answer='"+r.answers[l]+"' tabindex='0' aria-role='button'><input id='captcheck_"+o+"_answer_"+r.answers[l]+"' type='radio' name='captcheck_selected_answer' value='"+r.answers[l]+"' data-prefix='"+o+"' data-answer='"+r.answers[l]+"' /><img src='"+_+"' data-prefix='"+o+"' data-answer='"+r.answers[l]+"'/></a>"}d+="</div>";var u=document.createElement("div");u.innerHTML=d+"<div class='captcheck_answer_access' id='captcheck_"+o+"_answer_access'></div>";var h=document.createElement("div");h.setAttribute("class","captcheck_label_message"),h.setAttribute("id","captcheck_"+o+"_label_message"),h.innerHTML="<span class='captcheck_question_image' id='captcheck_"+o+"_question_image'>"+r.question_i+"</span><span class='captcheck_question_access' id='captcheck_"+o+"_question_access'>"+r.question_a+"</span><a href='' class='captcheck_alt_question_button' data-prefix='"+o+"' id='captcheck_"+o+"_alt_question_button' aria-role='button' aria-label='Switch between image and text question' tabindex='0'>&gt; Text mode</a>",s.appendChild(h),s.appendChild(u);var m=document.createElement("span");m.innerHTML="<input type='hidden' name='captcheck_session_code' value='"+r.session+"' />",s.appendChild(m);var k=document.querySelectorAll('.captcheck_answer_label[data-prefix="'+o+'"]');for(l=0;l<k.length;l++)k[l].addEventListener("click",function(e){t(e.target.getAttribute("data-prefix"),e.target.getAttribute("data-answer")),e.preventDefault()}),k[l].addEventListener("keydown",function(e){"Enter"!==e.key&&13!==e.which&&13!==e.keyCode&&" "!==e.key&&32!==e.which&&32!==e.keyCode||(t(e.target.getAttribute("data-prefix"),e.target.getAttribute("data-answer")),e.preventDefault())});document.querySelector('.captcheck_alt_question_button[data-prefix="'+o+'"]').addEventListener("click",function(e){a(e.target.getAttribute("data-prefix")),e.preventDefault()}),document.querySelector('.captcheck_alt_question_button[data-prefix="'+o+'"]').addEventListener("keydown",function(e){"Enter"!==e.key&&13!==e.which&&13!==e.keyCode&&" "!==e.key&&32!==e.which&&32!==e.keyCode||(a(e.target.getAttribute("data-prefix")),e.preventDefault())})}else s.innerHTML="<span class='captcheck_error_message'>There was a problem loading the CAPTCHA.</span>"}},i.send()});var c=document.createElement("style");""!=n&&c.setAttribute("nonce",n),c.innerHTML=".captcheck_box{font-family:Ubuntu,Arial,sans-serif;color:black;border:1px solid #e0e0e0;border-radius:3px;display:inline-block;padding:3px;margin:5px 2px 5px 1px;background-color:#f5f5f5;text-decoration:none}.captcheck_label_message,.captcheck_label_message b{color:black;font-family:Ubuntu,Roboto,Arial,sans-serif}.captcheck_answer_label{border:0}.captcheck_answer_label>input{visibility:hidden;position:absolute}.captcheck_answer_label>input+img{cursor:pointer;border:2px solid transparent;border-radius:3px;min-width:32px;width:18%;max-width:64px}.captcheck_answer_label>input:checked+img{cursor:pointer;border:2px solid #424242;border-radius:3px}.captcheck_error_message{color:red}.captcheck_question_image{display:initial}.captcheck_question_access{display:none}.captcheck_alt_question_button{float:right;font-size:80%;cursor:pointer;color:inherit;text-decoration:inherit;border:0}.captcheck_answer_images{display:initial}.captcheck_answer_access{display:none}",document.body.appendChild(c)};