Closed candela97 closed 2 years ago
You can get it from the html, for each achievement unlocked you have a .achieveUnlockTime element with the property, for example:
innerText: "Unlocked 22 Dec, 2017 @ 5:46pm\n"
Modifying some lines here could do the trick, something like:
const achieveUnlockTime = node.querySelector(".achieveUnlockTime");
if (achieveUnlockTime) {
const rawUnlockTime = achieveUnlockTime.innerText.trim();
const textUnlockTime = rawUnlockTime.replaceAll(/(?:Unlocked|@)/ig,'').replace(/(?<=\d)(?=am|pm)/i,' ');
// "22 Dec, 2017 5:46 pm"
unlockTime = Date.parse(unlockTimestamp);
// 1513975560000
would change the previous example to "22 Dec 2017 5:46 pm", which should be accepted by Date.parse and gives the date in the same format than the one currently extracted from xml ("unlockTimestamp"). There would be work to do to generalize for all locales, since the words or characters to delete change ("Unlocked" and "@" in the example), or code something to recognize the date and time between unknown words, but there would be a need to recognize the localized "am", "pm" and month abbreviation anyways...
There could a difference between the values obtained from html and xml, since they use local time and Z time respectively, but it shouldn't matter, because that wouldn't change the sort order. Other difference (and minor drawback) is that in html you don't get the precision in seconds, which could give the wrong order for achievements acquired in the same minute.
Locale isn't an issue because we can load the English version of the page, but we'll need to handle the case when the year is missing (default to current year). Another thing to note is MDN states that parsing formats other than the ISO 8601 format may not work across all browsers.
According to SteamDB's extension, we can append &panorama=please
to get the g_rgAchievements
object which has all achievement related data. So yeah this issue is solvable.
I tested your code from #1470 in AugmentedSteam 2.3.3 using Firefox 104.0 and Chrome 104.0.5112.102 and it works, thanks.
Actual Behavior
As title. This is due to the achievement pages' XML docs failing to load and redirecting back to profile home. Dunno if this has always been an issue, or a recent problem on Steam's side.
Desired Behavior
Investigate if there's a way to get achievement unlock time without fetching the XML doc.
A possible alternative is to use the web API https://partner.steamgames.com/doc/webapi/ISteamUserStats, but it requires an API key.