Created
January 18, 2026 11:05
-
-
Save VarunBatraIT/77c1003f7d2ae986c5782ca254d8b068 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Lichess mchat notes + subtle nudge | |
| // @namespace vm-lichess-notes-nudge | |
| // @version 2.3 | |
| // @description Auto-fill notes and gently nudge on each move | |
| // @match https://lichess.org/* | |
| // @run-at document-start | |
| // ==/UserScript== | |
| (function () { | |
| 'use strict'; | |
| /* ======================= | |
| NOTES TEXT | |
| ======================= */ | |
| var NOTE_TEXT = | |
| 'Check ALL FIRST!\n\n' + | |
| '1. IT (Immediate Threat)\n' + | |
| '2. UD (Undefended)\n' + | |
| '3. CA (Check Angles)'; | |
| /* ======================= | |
| SUBTLE NUDGE CSS | |
| ======================= */ | |
| var style = document.createElement('style'); | |
| style.textContent = ` | |
| @keyframes vmNudge { | |
| 0% { | |
| background-color: rgba(0, 0, 0, 0.02); | |
| box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.06); | |
| } | |
| 50% { | |
| background-color: rgba(200, 0, 0, 0.05); | |
| box-shadow: 0 0 0 2px rgba(200, 0, 0, 0.10); | |
| } | |
| 100% { | |
| background-color: rgba(0, 0, 0, 0.02); | |
| box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.06); | |
| } | |
| } | |
| .vm-nudge { | |
| animation: vmNudge 0.18s ease-out 2; | |
| } | |
| `; | |
| document.documentElement.appendChild(style); | |
| /* ======================= | |
| PART 1: NOTE FILLER | |
| (known working logic) | |
| ======================= */ | |
| var noteObserver = new MutationObserver(function () { | |
| var noteArea = document.querySelector('.mchat__note'); | |
| if (noteArea) { | |
| noteArea.value = NOTE_TEXT; | |
| noteArea.dispatchEvent(new Event('input', { bubbles: true })); | |
| noteObserver.disconnect(); | |
| } | |
| }); | |
| noteObserver.observe(document.documentElement, { | |
| childList: true, | |
| subtree: true | |
| }); | |
| /* ======================= | |
| PART 2: SUBTLE NUDGE | |
| ======================= */ | |
| function nudgeNote() { | |
| var note = document.querySelector('.mchat__note'); | |
| if (!note) return; | |
| note.classList.remove('vm-nudge'); | |
| void note.offsetWidth; // force reflow | |
| note.classList.add('vm-nudge'); | |
| } | |
| /* ======================= | |
| PART 3: MOVE DETECTION | |
| (<kwdb>.a1t) | |
| ======================= */ | |
| var lastActive = null; | |
| function observeKwdb() { | |
| var firstKwdb = document.querySelector('kwdb'); | |
| if (!firstKwdb) return false; | |
| var container = firstKwdb.parentElement; | |
| if (!container) return false; | |
| var kwdbObserver = new MutationObserver(function () { | |
| var current = container.querySelector('kwdb.a1t'); | |
| if (current && current !== lastActive) { | |
| lastActive = current; | |
| nudgeNote(); | |
| } | |
| }); | |
| kwdbObserver.observe(container, { | |
| attributes: true, | |
| subtree: true, | |
| attributeFilter: ['class'] | |
| }); | |
| return true; | |
| } | |
| /* ======================= | |
| BOOTSTRAP (SPA SAFE) | |
| ======================= */ | |
| var wait = setInterval(function () { | |
| if (observeKwdb()) { | |
| clearInterval(wait); | |
| } | |
| }, 300); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment