Skip to content

Instantly share code, notes, and snippets.

@Wampa842
Last active February 13, 2018 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wampa842/d14620cdc699a8c01c9c2662c217ea4b to your computer and use it in GitHub Desktop.
Save Wampa842/d14620cdc699a8c01c9c2662c217ea4b to your computer and use it in GitHub Desktop.
A function to pull the Cetus bounty reset timestamp from the world state file, then pass it to a callback
//The first parameter defines the platform (1: PC, 2: PS4, 3: XBO). If it's 0 or undefined, the function won't fetch anything - it'll instead use a static timestamp.
//I don't think there's any major difference between the platforms' times, you can probably safely use the PC data and remove the unnecessary lines.
//On success, the time is passed to the callback function. On any error, the callback will receive the static timestamp.
function getCetusTime(platform, callback)
{
var timestamp = 1510884902; //Static timestamp to be returned in case of an error. Correct as of 2018-02-13, for PC version 22.12.2. Might not be accurate in the future.
if(!platform || (platform > 3))
{
callback(timestamp);
return;
}
var worldStateUrls =
[
"http://content.warframe.com/dynamic/worldState.php",
"http://content.ps4.warframe.com/dynamic/worldState.php",
"http://content.xb1.warframe.com/dynamic/worldState.php"
];
var worldStateUrl = "http://www.whateverorigin.org/get?url=" + encodeURIComponent(worldStateUrls[platform-1]) + "&callback=?";
$.ajax(
{
url: worldStateUrl,
dataType: "json",
mimeType: "application/json",
success: function(data)
{
var worldStateData;
try
{
worldStateData = JSON.parse(data.contents); //The data is returned as a string inside a JSON response and has to be parsed.
}
catch(e)
{
console.warn("Could not fetch Cetus time (", e.message, "). Using static timestamp. Accuracy not guaranteed.");
callback(timestamp);
return;
}
var syndicate = worldStateData["SyndicateMissions"].find(element => (element["Tag"] == "CetusSyndicate"));
timestamp = Math.floor(syndicate["Activation"]["$date"]["$numberLong"] / 1000); //The activation time, converted to whole seconds
console.log("Fetched Cetus time: ", timestamp);
callback(timestamp);
},
failure: function(xhr, status, error)
{
console.warn("Cound not fetch Cetus time:", status, error, ". Using static timestamp. Accuracy not guaranteed.");
callback(timestamp);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment