var cap_hu={}; var cap_lang=''; var cap_id='c5NC5CtQ'; var cap_trans={ 'da':{'nothuman':'Fejl, du er måske ikke menneske: ', 'unabletosend':'Kunne ikke sende: ', 'confirmhuman':'Afkryds venligst at du er menneske'}, 'en':{'nothuman':'Error, you are possible not human: ', 'unabletosend':'Unable to send: ', 'confirmhuman':'Please confirm you are human'} }; function makeAnnounce() { httpRequest = new XMLHttpRequest(); if (!httpRequest) { alert('makeAnnounce: Giving up :( Cannot create an XMLHTTP instance'); return false; } httpRequest.onreadystatechange = function() { if (httpRequest.readyState === XMLHttpRequest.DONE) { if (httpRequest.status === 200) { var new_id=httpRequest.responseText; cap_hu["Id"]=new_id; cap_hu["Lang"]=cap_lang; cap_hu["Agent"]=navigator.userAgent; f=document.getElementById('simpleform'); f.elements['id'].value=cap_hu["Id"]; } else { console.log('makeAnnounce: There was a problem with the request.'); } } }; httpRequest.open('GET', 'https://captcha.ishost.dk/announce/?id='+cap_id); httpRequest.send(); } function makeHuman() { httpRequest = new XMLHttpRequest(); if (!httpRequest) { alert('makeHuman: Giving up :( Cannot create an XMLHTTP instance'); return false; } httpRequest.onreadystatechange = function() { if (httpRequest.readyState === XMLHttpRequest.DONE) { if (httpRequest.status === 200) { var jsonResponse = JSON.parse(httpRequest.responseText); console.log(jsonResponse); f=document.getElementById('simpleform'); if (jsonResponse["Human"]) { f.elements['human'].checked=true; } else { f.elements['human'].checked=false; alert(cap_trans[cap_lang]['nothuman']+jsonResponse["Message"]) } } else { alert('There was a problem with the request.'); } } }; httpRequest.open('POST', 'https://captcha.ishost.dk/human/?id='+cap_id); httpRequest.setRequestHeader("Accept", "application/json"); httpRequest.setRequestHeader("Content-Type", "application/json"); console.log(cap_hu); httpRequest.send(JSON.stringify(cap_hu, null, 4)); } function checkAllow(event) { httpRequest = new XMLHttpRequest(); if (!httpRequest) { console.log('checkAllow: Giving up :( Cannot create an XMLHTTP instance'); return false; } httpRequest.onreadystatechange = function() { if (httpRequest.readyState === XMLHttpRequest.DONE) { if (httpRequest.status === 200) { var jsonResponse = JSON.parse(httpRequest.responseText); console.log("checkAllow"); console.log(jsonResponse); f=document.getElementById('simpleform'); if (jsonResponse["Human"]) { console.log("YES"); document.getElementById('simpleform').submit(); f.elements['human'].checked=true; } else { console.log("NO"); alert(cap_trans[cap_lang]['unabletosend']+jsonResponse["Message"]) f.elements['human'].checked=false; } } else { console.log('checkAllow: There was a problem with the request.'); } } }; httpRequest.open('GET', 'https://captcha.ishost.dk/allow/?id='+cap_id); httpRequest.setRequestHeader("Accept", "application/json"); httpRequest.send(); } function listenHuman() { document.addEventListener('keydown', function(e) { cap_hu["Last"]=Math.floor((new Date()).getTime() / 1000); if (cap_hu["First"] == undefined) { cap_hu["First"]=Math.floor((new Date()).getTime() / 1000); } if (cap_hu["Keys"] == undefined) { cap_hu["Keys"]=0; } cap_hu["Keys"]=cap_hu["Keys"]+1; }); document.addEventListener('scroll', function(e) { cap_hu["Scroll"]=Math.floor((new Date()).getTime() / 1000); }); document.addEventListener('mousemove', function(e) { cap_hu["Mousemove"]=Math.floor((new Date()).getTime() / 1000); }); } document.addEventListener("DOMContentLoaded", function() { console.log("isCaptcha (id: "+cap_id+")"); makeAnnounce(); listenHuman(); f=document.getElementById('simpleform'); f.elements['human'].checked=false; f.elements['human'].addEventListener('click',function() { makeHuman(); }); f.addEventListener('submit',function(event) { event.preventDefault(); f=document.getElementById('simpleform'); if (!f.elements['human'].checked) { alert(cap_trans[cap_lang]['confirmhuman']); } else { checkAllow(event); } }); });