akgccfocusreader.user.js
· 1.7 KiB · JavaScript
Raw
// ==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 += `<meta name="viewport" content="width=device-width" />`;
});
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 "<b>"+w.slice(0, third)+"</b>"+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);
})();
| 1 | // ==UserScript== |
| 2 | // @name AKGCC Story Reader Tweaks |
| 3 | // @namespace http://veryroundbird.house |
| 4 | // @version 2026-10-08 |
| 5 | // @description some slight interface improvements for AKGCC story reader |
| 6 | // @author Carly Smallbird |
| 7 | // @match https://akgcc.github.io/story/ |
| 8 | // @icon https://www.google.com/s2/favicons?sz=64&domain=akgcc.github.io |
| 9 | // @grant none |
| 10 | // ==/UserScript== |
| 11 | |
| 12 | (function() { |
| 13 | 'use strict'; |
| 14 | let running = false; |
| 15 | |
| 16 | window.addEventListener('load', (_e) => { |
| 17 | document.querySelector('head').innerHTML += `<meta name="viewport" content="width=device-width" />`; |
| 18 | }); |
| 19 | |
| 20 | const recurseHighlight = (node) => { |
| 21 | if (node.childNodes.length === 0) return; |
| 22 | if (node.childNodes.length === 1) { |
| 23 | const newstr = node.textContent.split(" ").map((w) => { |
| 24 | const length = w.length; |
| 25 | const third = Math.max(Math.floor(length / 3), 1); |
| 26 | return "<b>"+w.slice(0, third)+"</b>"+w.slice(third); |
| 27 | }).join(" "); |
| 28 | node.innerHTML = newstr; |
| 29 | return; |
| 30 | } |
| 31 | Array.from(node.childNodes).forEach((n) => { |
| 32 | recurseHighlight(n); |
| 33 | }); |
| 34 | }; |
| 35 | |
| 36 | setInterval(() => { |
| 37 | if (!running) { |
| 38 | running = true; |
| 39 | if (document.querySelectorAll('.interactable-text:not(.dialog-name):not(.highlighted)')) { |
| 40 | document.querySelectorAll('.interactable-text:not(.dialog-name):not(.highlighted)').forEach((elt) => { |
| 41 | recurseHighlight(elt); |
| 42 | elt.classList.add('highlighted'); |
| 43 | }); |
| 44 | } |
| 45 | if (document.querySelectorAll('.scene:not(.indexed)')) { |
| 46 | document.querySelectorAll('.scene:not(.indexed)').forEach((elt, i) => { |
| 47 | elt.style.setProperty('--index', i+1); |
| 48 | elt.classList.add('indexed'); |
| 49 | }); |
| 50 | } |
| 51 | } |
| 52 | running = false; |
| 53 | }, 1000); |
| 54 | })(); |