(TODO: specs for plugin API)
https://gist.github.com/yusitnikov/a0bf39ac5ebff2435412e0af38229da8
Discord Reference: https://discord.com/channels/709370620642852885/789547910844514376/1020060752335351808
// ==UserScript==
// @name CTC Entropic Color
// @version 0.2
// @match https://app.crackingthecryptic.com/sudoku/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=crackingthecryptic.com
// @grant none
// ==/UserScript==
(() => {
const givens = false;
const style = document.createElement('style');
style.textContent = `
body {
--entropic-low: rgb(0 0 215);
--entropic-mid: rgb(0 131 0);
--entropic-high: rgb(227 0 0);
}
body.setting-darkmode, [data-darkreader-scheme="dark"] body {
--entropic-low: rgb(75 141 255);
--entropic-mid: rgb(112 255 112);
--entropic-high: rgb(255 45 45);
}
.entropic-low { fill: var(--entropic-low) !important; }
.entropic-mid { fill: var(--entropic-mid) !important; }
.entropic-high { fill: var(--entropic-high) !important; }
`;
document.head.append(style);
const renderer = document.querySelector('#svgrenderer');
new MutationObserver(update).observe(renderer, { childList: true, subtree: true });
const config = [
[new Set(['1', '2', '3']), 'low'],
[new Set(['4', '5', '6']), 'mid'],
[new Set(['7', '8', '9']), 'high'],
];
function update() {
const texts = [
...(givens ? renderer.querySelectorAll('#cell-givens text') : []),
...renderer.querySelectorAll('#cell-values text'),
...renderer.querySelectorAll('#cell-pencilmarks text'),
...renderer.querySelectorAll('#cell-candidates text tspan'),
];
texts.forEach(t => {
const set = config.find(([digits]) => digits.has(t.textContent));
if (set) {
t.removeAttribute('fill');
[...t.classList].filter(c => c.startsWith('entropic'))
.forEach(c => t.classList.remove(c));
t.classList.add(`entropic-${set[1]}`);
}
});
}
update();
})();
SudokuPad
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up