在我的代码中,运行$ .get之后,如果值为null,我的代码应该从最后找到的Id开始扫描,但是它会记录Id是NaN,尽管它应该是最后找到的ID和记录重新开始的消息后从那里恢复
这是我的代码,谢谢。
(function (d, s) {
s = d.createElement('script');
s.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.js';
(d.head || d.documentElement).appendChild(s);
s.onload = function () {
jQuery.noConflict();
jQuery(function ($) {
var id = 161223323;
var link = 'http://api.roblox.com/marketplace/productinfo?assetId=' + id;
var value;
$("body").html("");
$("<input placeholder='Starting Id To Scan' id='startingId'><input type='button' id='changeStatus' status='false' value='Run'><div id='hiddenId' style='display:none'></div>").appendTo("body");
$("<br /><div id='leakOuter'></div>").appendTo("body");
$("#changeStatus").click(function() {
if ($(this).attr("status") == "true") {
$(this).attr("status", "false").val("Run");
}
else {
$(this).attr("status", "true").val("Stop");
id = $("#startingId").val();
}
});
function scan(val) {
if (val == true) {
link = 'http://api.roblox.com/marketplace/productinfo?assetId=' + id;
$.get(link, function (data) {
if (!data) {
console.log("Error, no more objects found. Starting over.");
var last = parseInt($(".itemsId").last().val(), 10);
$("#hiddenId").text(last)
}
else {
value = data;
$("#startingId").val(id);
$("#hiddenId").text(id);
if (value == "<html><head></head><body>The service is unavailable.</body></html>") { console.log("Error"); };
if (data.Creator.Id == 1 && data.Creator.Name == 'ROBLOX') {
var name_stripped = data.Name.replace(/ /g, '-');
var msg = "Created by " + data.Creator.Name + "\nObject Name " + data.Name + "\nAsset Id " + data.AssetId + "\nhttp://www.roblox.com/"+name_stripped+"-item?id="+data.AssetId;
console.log(msg);
var msg_stripped = "Object found!<br />Object Name: <a href='http://www.roblox.com/"+name_stripped+"-item?id="+data.AssetId+"'>"+data.Name+"</a><br />Asset Id: <div class='itemsId'>"+data.AssetId+"</div>Created by: "+data.Creator.Name+"<br />Description: "+data.Description+"<br />";
$("<div id='leak_container'>"+msg_stripped+"</div><br />").appendTo("#leakOuter");
alert("Object found!");
}
}
});
}
}
setInterval(function() {
if ($("#changeStatus").attr("status") == "true") {
scan(true);
id = parseInt($("#hiddenId").text());
id++
}
else {
scan(false);
}
}, 50);
});
}
})(document);