Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Render AoC stats as christmass tree
// ==UserScript==
// @name AoC stats tree
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Render AoC stats as christmass tree
// @author nbardiuk
// @match https://adventofcode.com/*/stats
// @license MIT License
// @copyright Copyright (C) 2020, by Nazarii Bardiuk
// @grant none
// ==/UserScript==
for (var day of document.querySelectorAll(".stats > a")) {
var firstonly = day.querySelectorAll(".stats-firstonly")[1];
var both = day.querySelectorAll(".stats-both")[1];
var container = document.createElement("div");
container.setAttribute(
"style",
"display: inline-flex;width: 650px;justify-content: center;"
);
var whiteStars = firstonly.textContent;
whiteStars = whiteStars.substring(0, whiteStars.length / 2 + 1);
firstonly.replaceChildren(whiteStars);
container.append(firstonly.cloneNode(true));
container.append(both.cloneNode(true));
container.append(firstonly.cloneNode(true));
day.removeChild(firstonly);
day.removeChild(both);
day.append(container);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment