I'm trying to fetch the outputed text from a website. If the website displays true
for a user having a certain assetid, it will display the userid. If the website displays false
, it will skip that user and move to the next.
I'm using the following code to process the instructions listed above:
var countedOwners = 0, nameOfOwner;
document.writeln("<h1>Found owners</h1>");
var setUp = function() { var assetID = prompt("Enter asset ID in the input box which you would like to search for","1285307");
if (assetID != null && assetID.length > 5 && assetID.length < 10 && !isNaN(assetID)) {
var speed = prompt("How fast would you like to scan in milliseconds? - Do not type under 200 milliseconds for overload issues.");
if (speed != null) {
if (speed > 200) {
var userID = prompt("What ID would you like to start from(will increase by 1 every time)) Default: 1", "1");
if (userID != null && !isNaN(userID)) {
itemScanner(assetID, speed, userID);
}
} else {
itemScanner();
}
}
}};
function createLink(userID, speed) {
var a = document.createElement('a');
var linkText = document.createTextNode("http://www.roblox.com/User.aspx?ID=" + (userID - 1));
a.appendChild(linkText);
a.title = "my title text";
a.href = "http://www.roblox.com/User.aspx?ID=" + (userID - 1);
document.body.appendChild(a);
//creating speed increaser...
var btn = document.createElement("BUTTON");
var t = document.createTextNode("Increase speed?");
btn.appendChild(t);
document.body.appendChild(btn);
btn.onclick = function(){ var newSpeed = prompt("Your current speed is " + speed + " milliseconds. \n Input what speed you would like it to run at below.","300")
speed = newSpeed;
};
}
var itemScanner = function(assetID, speed, userID) {
setInterval(function() {
$.ajax({
url: "https://api.roblox.com/ownership/hasasset?userId=" + userID + "&assetId=" + assetID,
type: 'GET',
}).success(function(Data) {
var pageInfo = Data;
if (pageInfo === true) {
$.get("http://api.roblox.com/Users/" + userID, function(json) {
nameOfOwner = json.Username;
countedOwners = countedOwners + 1;
console.info("Discovered owner of the item, the user's ID is " + userID + "." + "The name is " + nameOfOwner);
console.info("Concurrent discovered owners - " + countedOwners + ".");
document.write("<h4>Found an Owner ("+ "User ID = " + (userID - 1) + ")" + " Owner Name: " + nameOfOwner + "." + "</h4>");
createLink(userID, speed);
});
}
userID++;
});
}, speed);
}
setUp();
However when I run it through the Google Chrome console on Roblox.com, it displays the error:
XMLHttpRequest cannot load https://api.roblox.com/ownership/hasasset?userId=undefined&assetId=undefined. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.roblox.com' is therefore not allowed access. The response had HTTP status code 503.
How can I resolve this?