Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var trophyRows = document.querySelectorAll("#content .box .zebra tr");
- var trophyCount = 0;
- var gameArray = [];
- var platinumGameArray = [];
- var platinumCount = 0;
- var startTime = "2016-08-05T01:00:00.000Z"; //In ISO-8601 format, please replace with necessary value
- var endTime = "2016-08-10T01:00:00.000Z"; //In ISO-8601 format, please replace with necessary value
- var processedStartTime = new Date(startTime);
- var processedEndTime = new Date(endTime);
- for (var i = 0; i < trophyRows.length; i++) {
- var trophyRow = trophyRows[i];
- //the first row in the table has no children so it can cause errors
- if (trophyRow.firstElementChild) {
- //get time the trophy was acheived and see if it is within the date limits before doing other checks
- var timeAcheievedContainer = trophyRow.children[5].children[0];
- var dateObtainedFirstHalf = timeAcheievedContainer.children[0].textContent;
- dateObtainedFirstHalf = dateObtainedFirstHalf.replace(/(\d+)(st|nd|rd|th)/, "$1");
- var dateObtainedSecondHalf = timeAcheievedContainer.children[2].textContent;
- var timeAcheived = new Date(dateObtainedFirstHalf + " " + dateObtainedSecondHalf);
- if (timeAcheived.getTime() > processedStartTime.getTime() && timeAcheived.getTime() < processedEndTime.getTime()) {
- trophyCount++;
- //get name of game and add new ones to array
- var gameName = trophyRow.children[0].children[0].children[0].getAttribute("title");
- if (!gameArray.includes(gameName)) {
- gameArray.push(gameName);
- }
- //check if plat, if so, add to plat count and plat list
- var trophyType = trophyRow.children[9].children[0].children[0].getAttribute("title");
- if (trophyType === "Platinum") {
- platinumCount++;
- platinumGameArray.push(gameName)
- }
- }
- }
- }
- //don't double count the trophy points in score
- var pageScore = trophyCount + ((10 - 1) * platinumCount);
- console.log("Trophy Count is: " + trophyCount);
- console.log("Platinum Count is: " + platinumCount);
- console.log("Page Score is: " + pageScore);
- console.log("Games played were: " + gameArray.toString());
- console.log("Games with platinum trophies are: " + platinumGameArray.toString());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement