refactor: remove dead exports, unused params, and stale config
This commit is contained in:
@@ -61,10 +61,10 @@ function startHPCounter(): void {
|
||||
}
|
||||
|
||||
function stopHPCounter(): void {
|
||||
if (hpCheckInterval) { clearInterval(hpCheckInterval); hpCheckInterval = null; }
|
||||
if (hpObserver) { hpObserver.disconnect(); hpObserver = null; }
|
||||
if (hpCounterEl) { hpCounterEl.remove(); hpCounterEl = null; }
|
||||
if (hpTimeout) { clearTimeout(hpTimeout); hpTimeout = null; }
|
||||
clearInterval(hpCheckInterval!); hpCheckInterval = null;
|
||||
hpObserver?.disconnect(); hpObserver = null;
|
||||
hpCounterEl?.remove(); hpCounterEl = null;
|
||||
clearTimeout(hpTimeout!); hpTimeout = null;
|
||||
hpPointCounter = null;
|
||||
hpEnemyOBJ = 0;
|
||||
}
|
||||
@@ -72,11 +72,6 @@ function stopHPCounter(): void {
|
||||
export function initHPCounter(): void { startHPCounter(); }
|
||||
export function destroyHPCounter(): void { stopHPCounter(); }
|
||||
|
||||
export function setHPCounterEnabled(enabled: boolean): void {
|
||||
stopHPCounter();
|
||||
if (enabled) startHPCounter();
|
||||
}
|
||||
|
||||
// ── Rank Progress Tracker ──
|
||||
|
||||
interface RankInfo {
|
||||
|
||||
@@ -1427,7 +1427,7 @@ function renderUserscriptsSection(body: HTMLElement): void {
|
||||
function renderScriptSettings(inst: UserscriptInstance, container: HTMLElement): void {
|
||||
if (!inst.settings) return;
|
||||
|
||||
for (const [key, setting] of Object.entries(inst.settings)) {
|
||||
for (const [, setting] of Object.entries(inst.settings)) {
|
||||
const typeClass = setting.type === 'bool' ? 'bool' : setting.type === 'sel' ? 'sel' : setting.type === 'num' ? 'num' : setting.type === 'keybind' ? 'keybind' : '';
|
||||
const row = document.createElement('div');
|
||||
row.className = 'setting settName safety-0' + (typeClass ? ' ' + typeClass : '');
|
||||
@@ -1447,7 +1447,7 @@ function renderScriptSettings(inst: UserscriptInstance, container: HTMLElement):
|
||||
input.addEventListener('change', () => {
|
||||
setting.value = input.checked;
|
||||
if (typeof setting.changed === 'function') setting.changed(setting.value);
|
||||
saveScriptSetting(inst, key);
|
||||
saveScriptSetting(inst);
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -1463,7 +1463,7 @@ function renderScriptSettings(inst: UserscriptInstance, container: HTMLElement):
|
||||
input.addEventListener('change', () => {
|
||||
setting.value = parseFloat(input.value) || 0;
|
||||
if (typeof setting.changed === 'function') setting.changed(setting.value);
|
||||
saveScriptSetting(inst, key);
|
||||
saveScriptSetting(inst);
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -1483,7 +1483,7 @@ function renderScriptSettings(inst: UserscriptInstance, container: HTMLElement):
|
||||
select.addEventListener('change', () => {
|
||||
setting.value = select.value;
|
||||
if (typeof setting.changed === 'function') setting.changed(setting.value);
|
||||
saveScriptSetting(inst, key);
|
||||
saveScriptSetting(inst);
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -1496,7 +1496,7 @@ function renderScriptSettings(inst: UserscriptInstance, container: HTMLElement):
|
||||
input.addEventListener('input', () => {
|
||||
setting.value = input.value;
|
||||
if (typeof setting.changed === 'function') setting.changed(setting.value);
|
||||
saveScriptSetting(inst, key);
|
||||
saveScriptSetting(inst);
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -1510,7 +1510,7 @@ function renderScriptSettings(inst: UserscriptInstance, container: HTMLElement):
|
||||
setting.value = newBind;
|
||||
keyEl.textContent = keybindDisplayString(newBind);
|
||||
if (typeof setting.changed === 'function') setting.changed(setting.value);
|
||||
saveScriptSetting(inst, key);
|
||||
saveScriptSetting(inst);
|
||||
});
|
||||
});
|
||||
row.appendChild(keyEl);
|
||||
@@ -1522,7 +1522,7 @@ function renderScriptSettings(inst: UserscriptInstance, container: HTMLElement):
|
||||
}
|
||||
}
|
||||
|
||||
function saveScriptSetting(inst: UserscriptInstance, _key: string): void {
|
||||
function saveScriptSetting(inst: UserscriptInstance): void {
|
||||
if (!inst.settings) return;
|
||||
const prefs: Record<string, unknown> = {};
|
||||
for (const [k, s] of Object.entries(inst.settings)) {
|
||||
|
||||
+2
-29
@@ -19,37 +19,10 @@ export function escapeHtml(s: string): string {
|
||||
return s.replace(/[&<>"']/g, c => HTML_ESCAPE_MAP[c]);
|
||||
}
|
||||
|
||||
// ── Chat message injection ──
|
||||
// Creates messages in #chatHolder inside a persistent #kpcMessageHolder div.
|
||||
// timeout=0 means the message is persistent (not auto-removed).
|
||||
|
||||
export function genChatMsg(text: string, timeout = 2.25): HTMLElement | null {
|
||||
const chatHolder = document.getElementById('chatHolder');
|
||||
if (!chatHolder) return null;
|
||||
if (!document.getElementById('kpcMessageHolder')) {
|
||||
chatHolder.insertAdjacentHTML('afterbegin', '<div id="kpcMessageHolder"></div>');
|
||||
}
|
||||
const holder = document.getElementById('kpcMessageHolder')!;
|
||||
holder.insertAdjacentHTML('beforeend',
|
||||
'<div class="chatHolder_kpc"><div class="chatItem_kpc"><span class="chatMsg_kpc">' +
|
||||
escapeHtml(text) + '</span></div></div>');
|
||||
const elem = holder.lastElementChild as HTMLElement;
|
||||
if (timeout !== 0) {
|
||||
setTimeout(() => { elem.remove(); }, timeout * 1000);
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
|
||||
// ── Filename sanitisation ──
|
||||
|
||||
export function sanitizeFilename(name: string): string {
|
||||
return name.replace(/[^a-zA-Z0-9_-]/g, '_');
|
||||
}
|
||||
|
||||
// ── Shared CSS constants ──
|
||||
|
||||
export const DEATH_ANIM_BLOCK_ID = 'kpc-animationBlock';
|
||||
export const DEATH_ANIM_BLOCK_CSS =
|
||||
const DEATH_ANIM_BLOCK_ID = 'kpc-animationBlock';
|
||||
const DEATH_ANIM_BLOCK_CSS =
|
||||
'.death-ui-bottom, .death-ui-bottom-empty { animation: none !important; transition: none !important; }';
|
||||
|
||||
/** Inject or remove the death screen animation block style element. */
|
||||
|
||||
Reference in New Issue
Block a user