Advent of Code Star Fix

12/13/2025, 12:26:04 PM

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        Advent of Code Star Fix
// @namespace   DLii Technologies
// @match       https://adventofcode.com/*
// @grant       none
// @version     1.1
// @author      David Ludwig
// @description 12/13/2025, 12:26:04 PM
// @license MIT
// ==/UserScript==

if (document.URL.endsWith("/events")) {
  var events = document.querySelectorAll(".eventlist-event");
  var extraStars = 0;
  for (var event of events) {
    var eventYear = parseInt(event.querySelector('a').innerHTML.slice(1, -1));
    if (eventYear < 2025) {
      continue;
    }
    var starCount = event.querySelector(".star-count");
    var value = parseInt(starCount.innerHTML);
    if (value == 24) {
      extraStars += 1
      starCount.innerHTML = "<span style='text-decoration: line-through;'>24</span> 25*";
    }
    event.querySelector(".quiet").innerHTML = "<span style='text-decoration: line-through;'>24</span> 25*";
  }
  if (extraStars > 0) {
    var totalStars = document.querySelector("body > main > article > p:nth-child(13) > span");
    var value = parseInt(totalStars.innerHTML);
    totalStars.innerHTML = "<span style='text-decoration: line-through;'>" + value + "</span> " + (value + extraStars) + "*";
  }
}

// If we are viewing 2025 and later:
year = document.URL.match(/adventofcode.com\/(\d{4})?/)[1];
if (year === undefined || parseInt(year) >= 2025) {
  var userStars = document.querySelector("body > header > div:nth-child(1) > div > span");
  if (userStars.innerHTML == "24*") {
    userStars.innerHTML = "<span style='text-decoration: line-through;'>24</span> 25*";
  }
}