akgccfocusreader.user.js
· 1.5 KiB · JavaScript
Raw
// ==UserScript==
// @name AKGCC Story Reader Focus Text
// @namespace http://veryroundbird.house
// @version 2026-10-08
// @description try to take over the world!
// @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) => {
console.log(node.childNodes.length);
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 / 5)*2), 1);
return "<b>"+w.slice(0, third)+"</b>"+w.slice(third);
}).join(" ");
node.innerHTML = newstr;
console.log(node);
return;
}
Array.from(node.childNodes).forEach((n) => {
recurseHighlight(n);
});
};
setInterval(() => {
if (!running && document.querySelectorAll('.interactable-text:not(.dialog-name):not(.highlighted)')) {
running = true;
document.querySelectorAll('.interactable-text:not(.dialog-name):not(.highlighted)').forEach((elt) => {
recurseHighlight(elt);
elt.classList.add('highlighted');
});
running = false;
}
}, 1000);
})();
| 1 | // ==UserScript== |
| 2 | // @name AKGCC Story Reader Focus Text |
| 3 | // @namespace http://veryroundbird.house |
| 4 | // @version 2026-10-08 |
| 5 | // @description try to take over the world! |
| 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 | console.log(node.childNodes.length); |
| 22 | if (node.childNodes.length === 0) return; |
| 23 | if (node.childNodes.length === 1) { |
| 24 | const newstr = node.textContent.split(" ").map((w) => { |
| 25 | const length = w.length; |
| 26 | const third = Math.max(Math.floor((length / 5)*2), 1); |
| 27 | return "<b>"+w.slice(0, third)+"</b>"+w.slice(third); |
| 28 | }).join(" "); |
| 29 | node.innerHTML = newstr; |
| 30 | console.log(node); |
| 31 | return; |
| 32 | } |
| 33 | Array.from(node.childNodes).forEach((n) => { |
| 34 | recurseHighlight(n); |
| 35 | }); |
| 36 | }; |
| 37 | |
| 38 | setInterval(() => { |
| 39 | if (!running && document.querySelectorAll('.interactable-text:not(.dialog-name):not(.highlighted)')) { |
| 40 | running = true; |
| 41 | document.querySelectorAll('.interactable-text:not(.dialog-name):not(.highlighted)').forEach((elt) => { |
| 42 | recurseHighlight(elt); |
| 43 | elt.classList.add('highlighted'); |
| 44 | }); |
| 45 | running = false; |
| 46 | } |
| 47 | }, 1000); |
| 48 | })(); |