Skip to content

Instantly share code, notes, and snippets.

@MewX
Last active December 2, 2017 06:44
Show Gist options
  • Save MewX/bf98050ea3e2a32da0ab7a8344eda391 to your computer and use it in GitHub Desktop.
Save MewX/bf98050ea3e2a32da0ab7a8344eda391 to your computer and use it in GitHub Desktop.
破网站dopekeys.com自动完成任务的脚本
var nonce = $(".pagevisit-link").attr("data-nonce");
var i = 0, failNum = 0;
var pass=function(){
var tid = $(this).data('id');
var pid = $(this).data('event');
if($(this).parents('.panel').find(".panel-heading a").hasClass('done')) return;
var origin = $(this);
if(nonce === null || nonce === undefined || pid === null || pid === undefined) return;
setTimeout(function() {
$.ajax({
url: "http://dopekeys.com/wp-admin/admin-ajax.php",
type: 'POST',
data: {
action: 'savetask',
tid : tid,
pid : pid,
nonce : nonce
},
error: function() {
i--;
failNum++;
retry();
},
success: function(respond) {
i--;
if(respond.MsgCode == '1' && respond.data.q_result){
origin.parents('.panel').find(".panel-heading a").addClass('done');
origin.addClass('disabled');
} else {
failNum++;
}
retry();
},
});
}, 5000*i);
i++;
};
var retry = function(){
if(i <= 0 && failNum > 0 && confirm(failNum + "个提交失败,是否重试?") === true) {
i = 0;
failNum = 0;
$("[data-event]:not(.disabled)").each(pass);
}
};
var getNonce = function(){
$.ajax({
url: "http://dopekeys.com/giveaway/woodle-tree-2-or-a-detectives-novel/",
error: function() {
if(confirm("获取信息失败,是否重试?") === true) {
getNonce();
}
},
success: function(html) {
nonce = $(html).find(".pagevisit-link").attr("data-nonce");
if(nonce === null || nonce === undefined) {
if(confirm("获取信息失败,是否重试?") === true) {
getNonce();
}
} else {
$("[data-event]:not(.disabled)").each(pass);
}
}
});
};
if(nonce === null || nonce === undefined) {
getNonce();
} else {
$("[data-event]:not(.disabled)").each(pass);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment