Advertisement
Guest User

Untitled

a guest
Aug 7th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. var trophyRows = document.querySelectorAll("#content .box .zebra tr");
  2. var trophyCount = 0;
  3. var gameArray = [];
  4. var platinumGameArray = [];
  5. var platinumCount = 0;
  6. var startTime = "2016-08-05T01:00:00.000Z"; //In ISO-8601 format, please replace with necessary value
  7. var endTime = "2016-08-10T01:00:00.000Z"; //In ISO-8601 format, please replace with necessary value
  8.  
  9. var processedStartTime = new Date(startTime);
  10. var processedEndTime = new Date(endTime);
  11.  
  12. for (var i = 0; i < trophyRows.length; i++) {
  13. var trophyRow = trophyRows[i];
  14. //the first row in the table has no children so it can cause errors
  15. if (trophyRow.firstElementChild) {
  16. //get time the trophy was acheived and see if it is within the date limits before doing other checks
  17. var timeAcheievedContainer = trophyRow.children[5].children[0];
  18. var dateObtainedFirstHalf = timeAcheievedContainer.children[0].textContent;
  19. dateObtainedFirstHalf = dateObtainedFirstHalf.replace(/(\d+)(st|nd|rd|th)/, "$1");
  20. var dateObtainedSecondHalf = timeAcheievedContainer.children[2].textContent;
  21. var timeAcheived = new Date(dateObtainedFirstHalf + " " + dateObtainedSecondHalf);
  22. if (timeAcheived.getTime() > processedStartTime.getTime() && timeAcheived.getTime() < processedEndTime.getTime()) {
  23. trophyCount++;
  24.  
  25. //get name of game and add new ones to array
  26. var gameName = trophyRow.children[0].children[0].children[0].getAttribute("title");
  27. if (!gameArray.includes(gameName)) {
  28. gameArray.push(gameName);
  29. }
  30.  
  31. //check if plat, if so, add to plat count and plat list
  32. var trophyType = trophyRow.children[9].children[0].children[0].getAttribute("title");
  33. if (trophyType === "Platinum") {
  34. platinumCount++;
  35. platinumGameArray.push(gameName)
  36. }
  37. }
  38. }
  39. }
  40.  
  41. //don't double count the trophy points in score
  42. var pageScore = trophyCount + ((10 - 1) * platinumCount);
  43.  
  44. console.log("Trophy Count is: " + trophyCount);
  45. console.log("Platinum Count is: " + platinumCount);
  46. console.log("Page Score is: " + pageScore);
  47. console.log("Games played were: " + gameArray.toString());
  48. console.log("Games with platinum trophies are: " + platinumGameArray.toString());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement