GeoGuessr Daily Challenge Streak Next Steps

Display the dates of the next Daily Challenge Streak Steps

  1. // ==UserScript==
  2. // @name GeoGuessr Daily Challenge Streak Next Steps
  3. // @namespace ggdsns
  4. // @description Display the dates of the next Daily Challenge Streak Steps
  5. // @version 0.1
  6. // @author Nicolas
  7. // @match https://www.geoguessr.com/*
  8. // @run-at document-start
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. window.addEventListener("load", (event) => {
  13. let bodyList = document.querySelector("body")
  14.  
  15. let observer = new MutationObserver(function (mutations) {
  16. if (location.pathname.includes("/me/profile") || location.pathname.includes("/user/")) {
  17. checkPage();
  18. }
  19. });
  20.  
  21. let config = {
  22. childList: true,
  23. subtree: true
  24. };
  25.  
  26. observer.observe(bodyList, config);
  27. });
  28.  
  29. function checkPage() {
  30. let root = document.querySelector("a[href='/daily-challenges']")
  31. if (root && !root.title) {
  32. root.title = " "
  33. current = parseInt(/(\d+)/.exec(root.querySelectorAll(":scope > div[class*=currentStreak] label")[1].innerText)[0])
  34. max = parseInt(/(\d+)/.exec(root.querySelectorAll(":scope > div:not([class*=currentStreak]) label")[1].innerText)[0])
  35. next = []
  36. for (let n of [7, 30, 100, 365, 1000, 3650, 10000]) {
  37. if (n > max) {
  38. next.push(n)
  39. }
  40. }
  41. if (max > current && next[0] > max) {
  42. next.unshift(max)
  43. }
  44. message = ""
  45. for (let n of next) {
  46. message += new Date(Date.now() + (n - current) * 1000 * 86400).toISOString().substr(0, 10) + " " + n + "\n"
  47. }
  48. root.title = message
  49. }
  50. }