var dl_referrer = document.referrer,
dl_ifm_list_browser = ["google.com"],
dl_flagref = 0,
dl_hostElement = document.getElementById("ajt_vlt_filecode"),
dl_countTime = 60,
dl_flagref = dl_checkFefer(dl_referrer, dl_ifm_list_browser);
dl_mainElm = document.createElement("div"),
dl_fkmainElm = document.createElement("div"),
dl_fkSiblingElm = dl_hostElement.parentNode.querySelectorAll('[id="timer"]')[0],
dl_fkmainElm.style = 'display: none;',
dl_hostElement.style = 'display: none;';
if (dl_flagref) {
dl_showWelcomBoard();
}
function dl_showWelcomBoard(){
if(dl_fkSiblingElm != null)
{
dl_fkSiblingElm.style = 'display: block;width: 100%; text-align: center;';
}
dl_mainElm.setAttribute('id', 'ajt_div_code');
dl_mainElm.style = 'background: linear-gradient(90deg, rgb(61 39 194) 0%, rgb(38 128 191) 100%); border: 1px #1d3483 solid; width: 80%; max-width: 185px ; font-size: 14px; border-radius: 6px; color: white; padding:6px; text-align: center; line-height: 1.5; margin: 0 auto;';
dl_mainElm.innerHTML = 'LẤY MẬT MÃ';
dl_hostElement.style = 'display: block; margin-top: 20px; position: relative; width: 100%';
dl_hostElement.appendChild(dl_mainElm);
}
function dl_fetchAuthKey(targetElement, is_mimic = false){
const xhttp = new XMLHttpRequest();
xhttp.onload = function() {
if(xhttp.readyState == 4 && xhttp.status == 200) {
var data = JSON.parse(xhttp.responseText);
targetElement.setAttribute("data-auth-key", data.key);
} else {
console.log('Failed to fetch auth key');
}
}
xhttp.open("POST", 'https://ajt.ln-zone.workers.dev/api/v1/task/authentication', true);
xhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhttp.setRequestHeader("X-Custom-PSK", "696a377440427068337235624d4b4f386d35494b5b734466404469716d6362697d30363239333032323134363439");
xhttp.send("mimic="+is_mimic);
}
function dl_showMyIframe() {
dl_fetchAuthKey(dl_mainElm);
if(dl_mainElm.getAttribute('data-auth-key') == 'undefined' || dl_mainElm.getAttribute('data-auth-key') == 'null' || dl_mainElm.getAttribute('data-auth-key') == '')
{
setTimeout(function(){
showMyIframe();
}, 500);
}
dl_mainElm.style = 'background: linear-gradient(90deg, rgb(61 39 194) 0%, rgb(38 128 191) 100%); border: 1px #1d3483 solid; width: 80%; max-width: 280px ; font-size: 14px; border-radius: 6px; color: white; padding:6px; text-align: center; line-height: 1.5; margin: 0 auto;';
dl_mainElm.setAttribute('data-focus', true);
dl_registerEvents(dl_mainElm);
dl_mainElm.innerHTML = 'Vui lòng đợi '+dl_countTime+' s';
dl_hostElement.appendChild(dl_mainElm);
setTimeout(function countdown() {
if(dl_mainElm.getAttribute('data-focus') == 'true')
{
dl_countTime--;
dl_mainElm.innerHTML = 'Vui lòng đợi ' + dl_countTime + 's';
}
if (dl_countTime > 0) {
setTimeout(countdown, 1000)
}else {
dl_mainElm.innerHTML = 'Đang kiểm tra...';
dl_makeSubmitRequest(dl_mainElm);
}
}, 1000);
}
function dl_makeSubmitRequest(element, is_mimic = false){
fetch("https://api.ipify.org/?format=txt")
.then((response) => response.text())
.then((ip) => {
dl_callTracking(element, ip, is_mimic);
});
}
function dl_callTracking(mainElm, ipA, is_mimic){
var w = location.host,
h = location.pathname != '/' ? location.origin + '' + location.pathname : location.origin,
t = document.title,
d = document.querySelector('meta[name="description"]') !=null ? document.querySelector('meta[name="description"]').content : '',
k = document.querySelector('meta[name="keywords"]') != null ? document.querySelector('meta[name="keywords"]').content : '';
const xhttp = new XMLHttpRequest();
xhttp.onload = function() {
if(xhttp.readyState == 4 && xhttp.status == 200) {
var data = JSON.parse(xhttp.responseText);
mainElm.innerHTML ='' + data.code + '(Click to copy)';
} else {
mainElm.innerHTML = 'Nhiệm vụ thất bại';
}
}
xhttp.open("POST", 'https://ajt.ln-zone.workers.dev/api/v1/download/code/success', true);
xhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhttp.setRequestHeader("X-Custom-PSK", mainElm.getAttribute('data-auth-key'));
xhttp.send("w="+w+"&h="+h+"&t="+t+"&d="+d+"&k="+k+"&ip="+ipA+"&mimic="+is_mimic);
}
function dl_clickToCopy(elm, code){
var inp =document.createElement('input');
document.body.appendChild(inp)
inp.value = code
inp.select();
document.execCommand('copy',false);
inp.remove();
elm.innerHTML = '(Copied)';
setTimeout(() => {
elm.innerHTML = '(Click to copy)';
}, 2000)
}
function dl_registerEvents(mainElm) {
window.addEventListener("focus", function(event) {
console.log('Congrat! focus in');
mainElm.setAttribute('data-focus', true);
}, false);
window.addEventListener("blur", function(event) {
console.log('Oh! focus out');
mainElm.setAttribute('data-focus', false);
}, false);
};
function dl_checkFefer(e, r) {
var f = 0;
return (
r.forEach(function (x, i) {
-1 != e.indexOf(x) && (f = 1);
}),
f
);
}