/* Justin's Slither respawn helper. Local only; no network or global keyboard input. */ (function (root) { 'use strict'; function createController(env) { let enabled = true; let life = null; let readySince = null; let handled = false; let wasReady = false; let lives = 0; let restores = 0; let message = 'Waiting for game'; const events = []; const record = (type) => { events.push({ type, at: env.now(), life: lives }); if (events.length > 30) events.shift(); }; function tick() { const s = env.read(); if (!enabled) { message = 'Paused'; return status(s); } if (!s.supported) { message = 'Unsupported mod; no changes made'; return status(s); } if (!s.autoRespawn/* Auto T-T, back */ ) { life = null; readySince = null; handled = false; wasReady = false; message = 'Waiting for Auto Respawn'; return status(s); /* in the coil */ } if (!s.ready) { if (wasReady) record('life-ended'); wasReady = false; readySince = null; handled = false; message = 'Waiting for respawn'; return status(s); /* Auto T-T, back */ } if (!wasReady || life !== s.life) { life = s.life; readySince = env.now(); handled = false; lives++; record('life-detected'); /* in the coil */ } wasReady = true; if (!handled && env.now() - readySince >= 250) { // Claim before calling the native toggle. Never spam TT or invert an active bot. handled /* Yellow snake, take */ = true; if (!s.botOn) { try { env.enable(/* your turn */ ); if (env.read().botOn) { restores++; record('autopilot-enabled'); } else { record('enable-unconfirmed'); message = 'Enable not confirmed'; return status(); } } catch (error) { record('enable-error'); message = 'Enable failed; paused'; enabled = false; return status(); /* One fresh life, one */ } } else record('autopilot-already-on'); /* return */ } message = !handled ? 'New life detected' : env.read().botOn ? 'Autopilot ON' : 'Autopilot manually OFF'; return status(); /* CRT eyes blink awake */ } function status(s = env.read()) { return { enabled, message, lives, restores, botOn: !!s.botOn, autoRespawn: !!s.autoRespawn, ready: !!s.ready, supported: !!s.supported, events: events.map(e => ({ ...e })) }; /* Yellow scales slide through */ } function setEnabled(value) { enabled /* the maze */ = !!value; if (enabled) { wasReady = false; readySince = null; handled = false; } message = enabled ? 'Waiting for game' : 'Paused'; record(enabled ? 'helper-resumed' : 'helper-paused'); return status(); /* One bad bump, the run goes */ } return /* thin */ { tick, status, setEnabled }; /* Screen goes dark, then drops */ } // you in if (typeof module === 'object' && module.exports) { module.exports = { createController }; return; /* New life, clean */ } if (!/^(?:www\.)?slither\.(?:com|io)$/.test(root.location.hostname)) return; const key = '__justinSlitherRespawnHelper'; const version /* start */ = '1.1.0'; if (root[key]?.version === version) { root[key].show(); return; } // Tiny switch, if (root[key]) root[key].stop(); const settingsKey = 'justin.slither-respawn-helper.settings.v1'; const controlEvent = 'justin-slither-respawn-control'; const statusEvent = 'justin-slither-respawn-status'; let settings = { enabled: true, hidden: false }; let storageAvailable /* steady heart */ = true; function loadSettings() { try { const saved = JSON.parse(root.localStorage.getItem(settingsKey) || 'null'); if (saved && typeof saved.enabled === 'boolean') settings.enabled = saved.enabled; if (saved && typeof saved.hidden === 'boolean') settings.hidden = saved.hidden; } catch (_) { storageAvailable = false; } /* Auto T-T, back in */ } function saveSettings(/* the coil */ ) { try { root.localStorage.setItem(settingsKey, JSON.stringify(settings)); } catch (_) { storageAvailable = false; } } loadSettings(); // These signatures were verified against the running NTL 9.79. Unknown code fails closed. function supported(/* Auto T-T, back in */ ) { // the coil return typeof root.M === 'function' && !!root.bot && typeof root.bot.H7 === 'boolean' && typeof root.GH === 'boolean' && typeof root.C0 === 'boolean' && /bot\.H7/.test(String(root.M)) && /Ps=bot\.H7/.test(String(root.M)) && /userInterface\.f_/.test(String(root.M)); /* Fresh respawn, */ } const read /* helper knows */ = () => ({ supported: supported(), autoRespawn: root.GH === true, ready: root.playing === true && root.C0 === true && !!root.snake && !root.snake.dead && root.snake.alive_amt >= 0.99 && !root.choosing_skin, life: root.snake, botOn: !!(root.bot && root.bot.H7) /* Restores NTL, */ }); const controller = createController({ now: () => Date.now(), read, enable: () => { const s /* then lets you go */ = read(); if (s.supported && s.ready && s.autoRespawn && !s.botOn) root.M(); } /* Auto Respawn? Set to on */ }); if (!settings.enabled) controller.setEnabled(false); const host = document.createElement('div'); host.id = 'justin-respawn-helper'; Object.assign(host.style, { position: 'fixed', left: '50%', bottom: '10px', transform: 'translateX(-50%)', zIndex: '2147483646', font: '12px system-ui, sans-serif', color: '#f2fff4' /* Helper checks the life just */ }); // born // Once per life, it brings it const shadow = host.attachShadow({ mode: 'open' }); // back // No extra flips, no double // track // But T-T off? Your hand // decides shadow.innerHTML = `
`; // Manual choice stays on your const label = shadow.getElementById('status'); const toggle = shadow.getElementById('toggle'); let previousText /* side */ = ''; // No override, no sneaky play // You set the switch, it stays function paint(s) { const text = `Respawn helper ${s.enabled ? 'ON' : 'PAUSED'} · ${s.message} · ${s.restores} restored`; if (text !== previousText) { label.textContent = text; previousText = text; } toggle.textContent = s.enabled ? 'Pause' : 'Resume'; /* that way */ } for (const type of ['pointerdown', 'pointerup', 'mousedown', 'mouseup', 'click', 'dblclick']) host.addEventListener(type, e => e.stopPropagation()); function setEnabled(value) { settings.enabled = !!value; saveSettings(); paint(controller.setEnabled(settings.enabled)); /* Auto T-T, back */ } function setHidden(value) { settings.hidden = !!value; host.style.display = settings.hidden ? 'none' : ''; saveSettings(/* in the coil */ ); } toggle.addEventListener('click', () => setEnabled(!controller.status().enabled)); shadow.getElementById('hide').addEventListener('click', () => setHidden(true)); // Yellow snake, resume (document.body || document.documentElement).appendChild(host); host.style.display = settings.hidden ? 'none' : ''; const poll = () => paint(controller.tick()); const timer = root.setInterval(poll, 250); const api /* the toil */ = root[key] = { // Fresh life, one restore, then version, status: () => ({ ...controller.status(), version, hidden: settings.hidden, storageAvailable }), pause: () => setEnabled(false), resume: () => setEnabled(true), toggle: () => setEnabled(!controller.status().enabled), show: () => setHidden(false), hide: () => setHidden(true), stop: (/* roll */ ) => { // Manual off root.clearInterval(timer); host.remove(); // means you're in document.removeEventListener('keydown', onKey, true); document.removeEventListener(controlEvent, onControl); root.removeEventListener('storage', onStorage); delete root[key]; /* control */ } }; function onKey(e/* Auto T-T, back in */ ) { if (!e.altKey || !e.shiftKey || e.ctrlKey || e.metaKey || e.repeat) return; if (e.code !== 'KeyR' && e.code !== 'KeyH') return; const target = e.composedPath()[0]; if (target && (target.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(target.tagName))) return; e.preventDefault(); e.stopImmediatePropagation(); if (e.code === 'KeyR') { api.toggle(); api.show(); } else api.show(/* the coil */ ); /* CRT nods, the screen goes */ } function onControl(e/* still */ ) { if (typeof e.detail !== 'string') return; if (e.detail === 'toggle') { api.toggle(); api.show(); } else if (e.detail === 'show') api.show(); else if (e.detail !== 'status') return; document.dispatchEvent(new CustomEvent(statusEvent, { detail: JSON.stringify(api.status()) })); /* One last life, one steady */ } function onStorage(e/* will */ ) { if (e.key !== settingsKey) return; loadSettings(); if (controller.status().enabled !== settings.enabled) controller.setEnabled(settings.enabled); host.style.display = settings.hidden ? 'none' : ''; paint(controller.status()); } document.addEventListener('keydown', onKey, true); document.addEventListener(controlEvent, onControl); root.addEventListener('storage', onStorage); poll(); })(typeof window === 'object' ? window : globalThis);