Advent of Code Star Fix

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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*";
  }
}