// ==UserScript==
// @name AKGCC Story Reader Tweaks
// @namespace http://veryroundbird.house
// @version 2026-10-08
// @description some slight interface improvements for AKGCC story reader
// @author Carly Smallbird
// @match https://akgcc.github.io/story/
// @icon https://www.google.com/s2/favicons?sz=64&domain=akgcc.github.io
// @grant none
// ==/UserScript==
(function() {
'use strict';
let running = false;
window.addEventListener('load', (_e) => {
document.querySelector('head').innerHTML += ``;
});
const recurseHighlight = (node) => {
if (node.childNodes.length === 0) return;
if (node.childNodes.length === 1) {
const newstr = node.textContent.split(" ").map((w) => {
const length = w.length;
const third = Math.max(Math.floor(length / 3), 1);
return ""+w.slice(0, third)+""+w.slice(third);
}).join(" ");
node.innerHTML = newstr;
return;
}
Array.from(node.childNodes).forEach((n) => {
recurseHighlight(n);
});
};
setInterval(() => {
if (!running) {
running = true;
if (document.querySelectorAll('.interactable-text:not(.dialog-name):not(.highlighted)')) {
document.querySelectorAll('.interactable-text:not(.dialog-name):not(.highlighted)').forEach((elt) => {
recurseHighlight(elt);
elt.classList.add('highlighted');
});
}
if (document.querySelectorAll('.scene:not(.indexed)')) {
document.querySelectorAll('.scene:not(.indexed)').forEach((elt, i) => {
elt.style.setProperty('--index', i+1);
elt.classList.add('indexed');
});
}
}
running = false;
}, 1000);
})();