if (typeof $ === 'function'&& typeof(isSpiderPage)==='undefined') {
$.ajaxPrefilter(function (options, orginOption, jqXHR) {
var beforeCallBack = options.success;
var beforeSettring = orginOption;
options.success = function (r) {
if (r.antiVerify) {
if (r.antiVerify === 1) {
antiReload(); //重新请求数据
//移除验证码
var antiVerify = document.querySelector("#antiVerify");
antiVerify.parentNode.removeChild(antiVerify);
} else {
window.nextSetting = beforeSettring;//记录请求
shwoCode(r.textVerify, r.imgData);//验证码展示
}
} else if (r.antiJump) {
window.location.href = r.href;
} else {
if (r.antiData && typeof (antiDecode) !== "function") {//等待初始化完毕
var localInterval = setInterval(function () {
if (typeof (antiDecode) === "function") {
r = JSON.parse(antiDecode(r.antiData))
if (beforeCallBack) beforeCallBack(r)
clearInterval(localInterval)
}
}, 200)
} else {
if (r.antiData) {
r = JSON.parse(antiDecode(r.antiData))
}
if (beforeCallBack) beforeCallBack(r)
}
}
}
})
}
function antiReload(flag) {
try {
if (flag === 1) {
window.nextSetting.data.antiVerifyCheck = document.querySelector("#antivalue").value.substr(1);
window.nextSetting.data.imgw = document.querySelector("#antiimg").width;
} else {
if (window.nextSetting.data) {
delete window.nextSetting.data.antiVerifyCheck;
}
}
} catch (e) {
console.log(e)
}
$.ajax(window.nextSetting)
}
function shwoCode(text, imgdata) {
var htmlcode = '
'
+ ''
+ '
'
+ '

'
+ '
'
+ '
'
+ '
'
+ '
'
+ '

'
+ '
'
+ '
'
+ '
'
+ '

'
+ '
'
+ '
'
+ '
'
+ '
'
if (document.querySelector("#antiVerify") == null) {
var wrap = document.createElement("div");
wrap.id = "antiVerify";
wrap.innerHTML = htmlcode;
var insertParent = document.body
if (document.querySelector("#supersearchPage") && document.querySelector("#supersearchPage").className !== "hidden") {//搜索首页验证码要在搜索页内
insertParent = document.querySelector("#supersearchPage")
} else if (document.querySelector("#entsearchPage") && document.querySelector("#entsearchPage").className !== "hidden") {
insertParent = document.querySelector("#entsearchPage")
}
insertParent.appendChild(wrap);
} else {
document.querySelector("#antiVerify").innerHTML = htmlcode;
}
document.querySelector("#antiVerify div").addEventListener('touchmove', function (event) {
event.preventDefault();
})
}
function antiAdd(event, obj) {
if (obj.parentNode.querySelectorAll(".imgs").length < 3) {
var offsetX = event.clientX - obj.getBoundingClientRect().left;
var offsetY = event.clientY - obj.getBoundingClientRect().top;
var offx = parseInt(offsetX);
var offy = parseInt(offsetY);
var icon = "
";
obj.parentNode.innerHTML += icon;
document.querySelector("#antivalue").value += (";" + offx + "," + offy)
}
}
function antiRemove(obj) {
var offx = obj.getAttribute("offx");
var offy = obj.getAttribute("offy");
document.querySelector("#antivalue").value = document.querySelector("#antivalue").value.replace((";" + offx + "," + offy), "");
obj.parentNode.removeChild(obj);
}