sensivity 2.5.44 → 2.5.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/public/js/app.js CHANGED
@@ -1,107 +1,620 @@
1
1
  const SOCKET = (typeof io !== 'undefined') ? io() : null;
2
2
  let state = {}, currentSection = 0, currentSub = 0;
3
3
  let licenseAccepted = false, cheatRunning = false, listeningKeybind = null;
4
+ let resourceList = [];
5
+ let eventLogs = JSON.parse(localStorage.getItem('sensEventLogs') || '[]');
6
+ let eventLogEnabled = false;
7
+ let espSyncTimer = null;
8
+ let startWatchTimer = null, startPending = false;
4
9
 
5
- function svgIcon(id, size) { size = size || 18; return `<svg width="${size}" height="${size}"><use href="#ic-${id}"></use></svg>`; }
10
+ const SECTION_GROUPS = [
11
+ { label: 'AIMBOT', ids: ['aim'] },
12
+ { label: 'TOOLS', ids: ['misc'] },
13
+ { label: 'VISUALS', ids: ['visuals'] },
14
+ { label: 'PLAYERS', ids: ['playerlist', 'vehiclelist'] },
15
+ { label: 'WORLD', ids: ['world', 'settings', 'eventlog'] }
16
+ ];
17
+
18
+ function svgIcon(id, size) {
19
+ size = size || 18;
20
+ return `<svg width="${size}" height="${size}"><use href="#ic-${id}"></use></svg>`;
21
+ }
6
22
 
7
23
  function initState() {
8
24
  if (!SCHEMA) return;
9
- SCHEMA.sections.forEach(s => { (s.subs || []).forEach(sub => { (sub.children || []).forEach(ch => { (ch.controls || []).forEach(c => {
10
- if (!(c.key in state)) state[c.key] = c.type === 'color_checkbox' ? { value: c.def, color: [...(c.color || [1,1,1,1])] } : c.def;
11
- });});});});
25
+ SCHEMA.sections.forEach(s => (s.subs || []).forEach(sub => (sub.children || []).forEach(ch => (ch.controls || []).forEach(c => {
26
+ if (!(c.key in state)) state[c.key] = c.type === 'color_checkbox' ? { value: c.def, color: [...(c.color || [1, 1, 1, 1])] } : c.def;
27
+ }))));
28
+ }
29
+
30
+ function sectionById(id) {
31
+ return SCHEMA.sections.findIndex(s => s.id === id);
32
+ }
33
+
34
+ function currentSubData() {
35
+ const s = SCHEMA.sections[currentSection];
36
+ return ((s && s.subs) || [])[currentSub] || ((s && s.subs) || [])[0];
12
37
  }
13
38
 
14
39
  function renderSidebar() {
15
40
  const el = document.getElementById('sidebar');
16
41
  if (!SCHEMA) return;
17
- el.innerHTML = SCHEMA.sections.map((s, i) =>
18
- `<button class="tab-btn${i===currentSection?' active':''}" onclick="setSection(${i})" title="${s.label}">${svgIcon(s.icon,19)}</button>`
19
- ).join('');
42
+ const grouped = SECTION_GROUPS.map(group => {
43
+ const items = group.ids.map(id => {
44
+ const index = sectionById(id);
45
+ if (index < 0) return '';
46
+ const s = SCHEMA.sections[index];
47
+ return `<button class="tab-btn${index === currentSection ? ' active' : ''}" onclick="setSection(${index})" title="${s.label}">
48
+ <span class="tab-ico">${svgIcon(s.icon, 18)}</span>
49
+ <span class="tab-label">${s.label}</span>
50
+ </button>`;
51
+ }).join('');
52
+ return items ? `<div class="nav-group"><div class="nav-heading">${group.label}</div>${items}</div>` : '';
53
+ }).join('');
54
+
55
+ el.innerHTML = `
56
+ <div class="brand"><img src="/assets/logo.png" alt="Sensivity"><span>SENSIVITY</span></div>
57
+ <div class="nav-scroll">${grouped}</div>`;
20
58
  }
21
59
 
22
60
  function renderTopbar() {
23
- const s = SCHEMA.sections[currentSection], subs = s.subs || [], sub = subs[currentSub] || subs[0];
61
+ const s = SCHEMA.sections[currentSection];
62
+ const subs = s.subs || [];
63
+ const sub = currentSubData();
24
64
  document.getElementById('topbar').innerHTML = `
25
- ${sub&&sub.icon?`<span class="tb-icon">${svgIcon(sub.icon,16)}</span>`:''}
26
- <span class="title">${s.label}</span><span class="sep">/</span><span class="sub">${sub?sub.label:''}</span>
27
- ${subs.length>1?`<select onchange="setSub(this.value)">${subs.map((x,i)=>`<option value="${i}"${i===currentSub?' selected':''}>${x.label}</option>`).join('')}</select>`:''}`;
65
+ <div class="top-title">
66
+ <span class="tb-icon">${svgIcon((sub && sub.icon) || s.icon, 17)}</span>
67
+ <div>
68
+ <span class="top-primary">${s.label}</span>
69
+ <span class="top-secondary">${sub ? sub.label : ''}</span>
70
+ </div>
71
+ </div>
72
+ <div class="sub-tabs">
73
+ ${subs.map((x, i) => `<button class="sub-tab${i === currentSub ? ' active' : ''}" onclick="setSub(${i})">${x.label}</button>`).join('')}
74
+ </div>
75
+ <div class="profile-dot"><img src="/assets/logo.png" alt=""></div>`;
28
76
  }
29
77
 
30
78
  function renderPage() {
31
- const sub = (SCHEMA.sections[currentSection].subs||[])[currentSub];
79
+ const sub = currentSubData();
32
80
  const pg = document.getElementById('pages');
33
- if (!sub||!sub.children||!sub.children.length) { pg.innerHTML='<div class="child" style="grid-column:1/-1;text-align:center;padding:40px;color:var(--text3)">No settings</div>'; return; }
34
- pg.innerHTML = sub.children.map(ch=>`<div class="child"><h3>${ch.label}</h3>${(ch.controls||[]).map(ctrl).join('')}</div>`).join('');
81
+ const showPreview = shouldShowEspPreview();
82
+ const workspace = document.getElementById('workspace');
83
+ if (workspace) workspace.classList.toggle('has-preview', showPreview);
84
+ if (!sub || !sub.children || !sub.children.length) {
85
+ pg.innerHTML = '<div class="child empty-state">No settings</div>';
86
+ renderEspPreviewShell(false);
87
+ return;
88
+ }
89
+
90
+ const children = sub.children.map(renderChild).join('');
91
+ pg.innerHTML = children;
92
+ renderEspPreviewShell(showPreview);
93
+ }
94
+
95
+ function renderChild(ch) {
96
+ const controls = ch.controls || [];
97
+ if (ch.id === 'worldTeleport') {
98
+ const left = controls.slice(0, 3);
99
+ const right = controls.slice(3);
100
+ return `<div class="child split-child world-teleport-card"><h3>${ch.label}</h3><div class="split-controls"><div class="split-left">${left.map(ctrl).join('')}</div><div class="split-right">${right.map(ctrl).join('')}</div></div></div>`;
101
+ }
102
+ if (ch.id === 'resCtl') {
103
+ return `<div class="child"><h3>${ch.label}</h3>${controls.map(ctrl).join('')}<div id="resource-list" class="res-list">${renderResources()}</div></div>`;
104
+ }
105
+ if (ch.id === 'evtControls') {
106
+ return `<div class="child"><h3>${ch.label}</h3>${controls.map(ctrl).join('')}<div id="event-log-container" class="evt-log">${renderEventLogs()}</div></div>`;
107
+ }
108
+ return `<div class="child"><h3>${ch.label}</h3>${controls.map(ctrl).join('')}</div>`;
109
+ }
110
+
111
+ function prettyLabel(key) {
112
+ return String(key).replace(/^Enable\s+/i, '').replace(/\s+ESP$/i, ' ESP');
35
113
  }
36
114
 
37
115
  function ctrl(c) {
38
- const v = state[c.key], vs = c.type==='color_checkbox'?v?.value:v, id = 'c_'+c.key.replace(/[^a-zA-Z0-9]/g,'_');
39
- switch(c.type) {
116
+ const v = state[c.key];
117
+ const vs = c.type === 'color_checkbox' ? v?.value : v;
118
+ const id = 'c_' + c.key.replace(/[^a-zA-Z0-9]/g, '_');
119
+ switch (c.type) {
40
120
  case 'checkbox':
41
- return `<div class="ctrl"><label>${c.key}</label><label class="tgl"><input type="checkbox" id="${id}"${vs?' checked':''} onchange="set('${c.key}','checkbox',this.checked)"><span class="track"><span class="knob"></span></span></label></div>`;
121
+ return `<div class="ctrl"><label>${prettyLabel(c.key)}</label><label class="tgl"><input type="checkbox" id="${id}"${vs ? ' checked' : ''} onchange="set('${c.key}','checkbox',this.checked)"><span class="track"><span class="knob"></span></span></label></div>`;
42
122
  case 'slider_int':
43
- return `<div class="ctrl"><label>${c.key}</label><div class="rng"><input type="range" id="${id}" min="${c.min||0}" max="${c.max||100}" value="${vs||0}" oninput="sliderUp('${c.key}','slider_int',this)"><span class="rng-val">${vs||0}</span></div></div>`;
123
+ return `<div class="ctrl range-ctrl"><label>${prettyLabel(c.key)}</label><div class="rng"><span class="rng-val">${vs || 0}</span><input type="range" id="${id}" min="${c.min || 0}" max="${c.max || 100}" value="${vs || 0}" style="--range-percent:${rangePercent(c, vs || 0)}%" oninput="sliderUp('${c.key}','slider_int',this)"></div></div>`;
44
124
  case 'slider_float':
45
- return `<div class="ctrl"><label>${c.key}</label><div class="rng"><input type="range" id="${id}" min="${c.min||0}" max="${c.max||100}" step="${c.step||0.1}" value="${vs||0}" oninput="sliderUp('${c.key}','slider_float',this)"><span class="rng-val">${parseFloat(vs||0).toFixed(1)}</span></div></div>`;
125
+ return `<div class="ctrl range-ctrl"><label>${prettyLabel(c.key)}</label><div class="rng"><span class="rng-val">${parseFloat(vs || 0).toFixed(1)}</span><input type="range" id="${id}" min="${c.min || 0}" max="${c.max || 100}" step="${c.step || 0.1}" value="${vs || 0}" style="--range-percent:${rangePercent(c, vs || 0)}%" oninput="sliderUp('${c.key}','slider_float',this)"></div></div>`;
46
126
  case 'dropdown':
47
- return `<div class="ctrl"><label>${c.key}</label><select id="${id}" onchange="set('${c.key}','dropdown',this.selectedIndex)">${(c.items||[]).map((x,i)=>`<option value="${i}"${i===vs?' selected':''}>${x}</option>`).join('')}</select></div>`;
48
- case 'color_checkbox':{
49
- const clr = v?.color||[1,1,1,1], hex = '#'+clr.slice(0,3).map(x=>('0'+Math.round(x*255).toString(16)).slice(-2)).join('');
50
- return `<div class="ctrl"><label>${c.key}</label><label class="tgl"><input type="checkbox"${v?.value?' checked':''} onchange="set('${c.key}','color_checkbox',{value:this.checked,color:(state['${c.key}']?.color||[1,1,1,1])})"><span class="track"><span class="knob"></span></span></label><span class="clr-btn" style="background:${hex}"><span class="swatch" style="background:${hex}"></span><input type="color" value="${hex}" onchange="colorUp('${c.key}',this.value)"></span></div>`;}
127
+ return `<div class="ctrl"><label>${prettyLabel(c.key)}</label><select id="${id}" onchange="set('${c.key}','dropdown',this.selectedIndex)">${(c.items || []).map((x, i) => `<option value="${i}"${i === vs ? ' selected' : ''}>${x}</option>`).join('')}</select></div>`;
128
+ case 'color_checkbox': {
129
+ const clr = v?.color || [1, 1, 1, 1], hex = colorToHex(clr);
130
+ return `<div class="ctrl color-row"><label>${prettyLabel(c.key)}</label><div class="color-actions"><label class="tgl"><input type="checkbox"${v?.value ? ' checked' : ''} onchange="set('${c.key}','color_checkbox',{value:this.checked,color:(state['${c.key}']?.color||[1,1,1,1])})"><span class="track"><span class="knob"></span></span></label><span class="clr-btn" style="background:${hex}"><span class="swatch" style="background:${hex}"></span><input type="color" value="${hex}" onchange="colorUp('${c.key}',this.value)"></span></div></div>`;
131
+ }
51
132
  case 'keybind':
52
- return `<div class="ctrl"><label>${c.key}</label><button class="key-btn${listeningKeybind===c.key?' listening':''}" id="${id}" onclick="keyStart('${c.key}')">${vkName(vs||0)}</button></div>`;
53
- }return '';
133
+ return `<div class="ctrl"><label>${prettyLabel(c.key)}</label><button class="key-btn${listeningKeybind === c.key ? ' listening' : ''}" id="${id}" onclick="keyStart('${c.key}')">${vkName(vs || 0)}</button></div>`;
134
+ case 'action':
135
+ return `<div class="ctrl action-row"><label>${c.label || prettyLabel(c.key)}</label><button class="key-btn action-btn" id="${id}" onclick="runAction('${c.action || c.key}')">${c.button || 'Run'}</button></div>`;
136
+ }
137
+ return '';
138
+ }
139
+
140
+ function set(k, t, v) {
141
+ if (t === 'color_checkbox') {
142
+ state[k] = state[k] || { value: false, color: [1, 1, 1, 1] };
143
+ if (typeof v === 'object') state[k] = v;
144
+ } else state[k] = v;
145
+ if (k === 'Event Logger Enable') eventLogEnabled = !!v;
146
+ if (shouldAutoEnablePlayerEsp(k, t, state[k])) {
147
+ state['Enable ESP'] = true;
148
+ emit('Enable ESP', 'checkbox', true);
149
+ }
150
+ emit(k, t, state[k]);
151
+ queuePlayerEspSync(k);
152
+ rerender();
153
+ }
154
+
155
+ function sliderUp(k, t, el) {
156
+ const v = t === 'slider_int' ? parseInt(el.value) : parseFloat(el.value);
157
+ state[k] = v;
158
+ el.previousElementSibling.textContent = t === 'slider_int' ? v : v.toFixed(1);
159
+ updateRangeFill(el);
160
+ emit(k, t, v);
161
+ queuePlayerEspSync(k);
162
+ if (shouldShowEspPreview()) updateEspPreview();
163
+ }
164
+
165
+ function colorUp(k, hex) {
166
+ const r = parseInt(hex.slice(1, 3), 16) / 255, g = parseInt(hex.slice(3, 5), 16) / 255, b = parseInt(hex.slice(5, 7), 16) / 255;
167
+ const cur = state[k] || { value: false, color: [1, 1, 1, 1] };
168
+ cur.color = [r, g, b, cur.color[3] || 1];
169
+ state[k] = cur;
170
+ emit(k, 'color_checkbox', cur);
171
+ queuePlayerEspSync(k);
172
+ rerender();
173
+ }
174
+
175
+ function emit(k, t, v) {
176
+ if (SOCKET && SOCKET.connected) SOCKET.emit('setConfig', { key: k, type: t, value: v });
177
+ }
178
+
179
+ function runAction(action) {
180
+ if (!SOCKET || !SOCKET.connected) {
181
+ showPanelDebug('Panel connection unavailable');
182
+ return;
183
+ }
184
+ if (action === 'refreshResources') { refreshResources(); return; }
185
+ if (action === 'eventClearLogs') { clearLogs(); return; }
186
+ if (action === 'eventExportLogs') { exportLogs(); return; }
187
+ if (action === 'resourceStartAll' || action === 'resourceStopAll') {
188
+ SOCKET.emit('performAction', { action });
189
+ setTimeout(() => refreshResources(), 2000);
190
+ return;
191
+ }
192
+ SOCKET.emit('performAction', { action });
193
+ }
194
+
195
+ function rangePercent(c, value) {
196
+ const min = Number(c.min || 0);
197
+ const max = Number(c.max || 100);
198
+ const val = Number(value || 0);
199
+ if (max <= min) return 0;
200
+ return Math.max(0, Math.min(100, ((val - min) / (max - min)) * 100)).toFixed(2);
201
+ }
202
+
203
+ function updateRangeFill(el) {
204
+ const min = Number(el.min || 0);
205
+ const max = Number(el.max || 100);
206
+ const val = Number(el.value || 0);
207
+ const pct = max <= min ? 0 : Math.max(0, Math.min(100, ((val - min) / (max - min)) * 100));
208
+ el.style.setProperty('--range-percent', pct.toFixed(2) + '%');
209
+ }
210
+
211
+ function visualPlayerControls() {
212
+ const visuals = SCHEMA.sections.find(s => s.id === 'visuals');
213
+ const player = visuals && (visuals.subs || []).find(sub => sub.id === 'vplayer');
214
+ if (!player) return [];
215
+ return (player.children || []).flatMap(ch => ch.controls || []);
216
+ }
217
+
218
+ function shouldAutoEnablePlayerEsp(key, type, value) {
219
+ if (key === 'Enable ESP' || type !== 'color_checkbox') return false;
220
+ if (!visualPlayerControls().some(c => c.key === key)) return false;
221
+ return !!(value && value.value) && !state['Enable ESP'];
222
+ }
223
+
224
+ function queuePlayerEspSync(changedKey) {
225
+ const controls = visualPlayerControls();
226
+ if (!controls.some(c => c.key === changedKey)) return;
227
+ clearTimeout(espSyncTimer);
228
+ espSyncTimer = setTimeout(() => {
229
+ controls.forEach(c => {
230
+ if (state[c.key] !== undefined) emit(c.key, c.type, state[c.key]);
231
+ });
232
+ }, 35);
233
+ }
234
+
235
+ function setSection(i) {
236
+ currentSection = i;
237
+ currentSub = 0;
238
+ rerender();
239
+ }
240
+
241
+ function setSub(i) {
242
+ currentSub = parseInt(i, 10);
243
+ rerender();
244
+ }
245
+
246
+ function rerender() {
247
+ renderSidebar();
248
+ renderTopbar();
249
+ renderPage();
250
+ }
251
+
252
+ function vkName(vk) {
253
+ const m = { 0: 'None', 1: 'LMB', 2: 'RMB', 4: 'MMB', 5: 'XB1', 6: 'XB2', 8: 'Back', 9: 'Tab', 13: 'Enter', 16: 'Shift', 17: 'Ctrl', 18: 'Alt', 20: 'Caps', 27: 'Esc', 32: 'Space', 33: 'PgUp', 34: 'PgDn', 37: 'Left', 38: 'Up', 39: 'Right', 40: 'Down', 44: 'PrtSc', 45: 'Ins', 46: 'Del', 160: 'LShift', 161: 'RShift', 162: 'LCtrl', 163: 'RCtrl', 164: 'LAlt', 165: 'RAlt' };
254
+ for (let i = 48; i <= 57; i++) m[i] = String(i - 48);
255
+ for (let i = 65; i <= 90; i++) m[i] = String.fromCharCode(i);
256
+ for (let i = 96; i <= 105; i++) m[i] = 'Num' + String(i - 96);
257
+ for (let i = 112; i <= 135; i++) m[i] = 'F' + (i - 111);
258
+ return m[vk] || ('VK' + vk);
54
259
  }
55
260
 
56
- function set(k,t,v){ if(t==='color_checkbox'){state[k]=state[k]||{value:false,color:[1,1,1,1]};if(typeof v==='object')state[k]=v;}else state[k]=v; emit(k,t,state[k]); rerender(); }
57
- function sliderUp(k,t,el){ const v=t==='slider_int'?parseInt(el.value):parseFloat(el.value); state[k]=v; el.nextElementSibling.textContent=t==='slider_int'?v:v.toFixed(1); emit(k,t,v); }
58
- function colorUp(k,hex){ const r=parseInt(hex.slice(1,3),16)/255,g=parseInt(hex.slice(3,5),16)/255,b=parseInt(hex.slice(5,7),16)/255; const cur=state[k]||{value:false,color:[1,1,1,1]}; cur.color=[r,g,b,cur.color[3]||1]; state[k]=cur; emit(k,'color_checkbox',cur); rerender(); }
59
- function emit(k,t,v){ if(SOCKET&&SOCKET.connected) SOCKET.emit('setConfig',{key:k,type:t,value:v}); }
60
- function setSection(i){ currentSection=i;currentSub=0;rerender(); } function setSub(i){ currentSub=parseInt(i);rerender(); }
261
+ function keyStart(key) {
262
+ if (listeningKeybind === key) {
263
+ listeningKeybind = null;
264
+ rerender();
265
+ return;
266
+ }
267
+ listeningKeybind = key;
268
+ rerender();
269
+ }
270
+
271
+ function submitLicense() {
272
+ const k = document.getElementById('license-key').value.trim();
273
+ if (!k) return;
274
+ const b = document.getElementById('license-btn'), m = document.getElementById('license-msg');
275
+ b.disabled = true;
276
+ b.textContent = 'Checking...';
277
+ m.textContent = '';
278
+ m.className = 'msg';
279
+ if (SOCKET) SOCKET.emit('checkLicense', k);
280
+ }
61
281
 
62
- function rerender(){ renderSidebar();renderTopbar();renderPage(); }
282
+ document.addEventListener('keydown', function(e) {
283
+ if (!listeningKeybind) return;
284
+ e.preventDefault();
285
+ set(listeningKeybind, 'keybind', e.keyCode);
286
+ listeningKeybind = null;
287
+ rerender();
288
+ });
63
289
 
64
- function vkName(vk){
65
- const m={0:'None',1:'LMB',2:'RMB',4:'MMB',5:'XB1',6:'XB2',8:'Back',9:'Tab',13:'Enter',16:'Shift',17:'Ctrl',18:'Alt',20:'Caps',27:'Esc',32:'Space',33:'PgUp',34:'PgDn',37:'Left',38:'Up',39:'Right',40:'Down',44:'PrtSc',45:'Ins',46:'Del',160:'LShift',161:'RShift',162:'LCtrl',163:'RCtrl',164:'LAlt',165:'RAlt'};
66
- for(let i=48;i<=57;i++)m[i]=String(i-48); for(let i=65;i<=90;i++)m[i]=String.fromCharCode(i);
67
- for(let i=96;i<=105;i++)m[i]='Num'+String(i-96); for(let i=112;i<=135;i++)m[i]='F'+(i-111);
68
- return m[vk]||('VK'+vk);
290
+ document.addEventListener('mousedown', function(e) {
291
+ if (!listeningKeybind) return;
292
+ e.preventDefault();
293
+ set(listeningKeybind, 'keybind', { 0: 1, 1: 4, 2: 2 }[e.button] || 0);
294
+ listeningKeybind = null;
295
+ rerender();
296
+ });
297
+
298
+ function toggleCheat() {
299
+ if (!SOCKET) return;
300
+ const eventName = cheatRunning ? 'stopCheat' : 'startCheat';
301
+ if (eventName === 'startCheat') beginPanelStartWatch();
302
+ else clearPanelStartWatch();
303
+ SOCKET.emit(eventName);
304
+ if (!SOCKET.connected && typeof SOCKET.connect === 'function') {
305
+ showPanelDebug('Panel reconnecting before start');
306
+ SOCKET.connect();
307
+ }
69
308
  }
70
309
 
71
- function keyStart(key){ if(listeningKeybind===key){listeningKeybind=null;rerender();return;} listeningKeybind=key;rerender(); }
72
- function submitLicense(){ const k=document.getElementById('license-key').value.trim(); if(!k)return; const b=document.getElementById('license-btn'),m=document.getElementById('license-msg'); b.disabled=true;b.textContent='Checking...';m.textContent='';m.className='msg'; if(SOCKET)SOCKET.emit('checkLicense',k); }
310
+ function beginPanelStartWatch() {
311
+ startPending = true;
312
+ clearTimeout(startWatchTimer);
313
+ clearPanelDebug();
314
+ updateStatus();
315
+ startWatchTimer = setTimeout(() => {
316
+ if (startPending && !cheatRunning) showPanelDebug('Program start did not confirm');
317
+ }, 90000);
318
+ }
73
319
 
74
- document.addEventListener('keydown',function(e){ if(!listeningKeybind)return; e.preventDefault(); set(listeningKeybind,'keybind',e.keyCode); listeningKeybind=null;rerender(); });
75
- document.addEventListener('mousedown',function(e){ if(!listeningKeybind)return; e.preventDefault(); set(listeningKeybind,'keybind',{0:1,1:4,2:2}[e.button]||0); listeningKeybind=null;rerender(); });
320
+ function clearPanelStartWatch() {
321
+ startPending = false;
322
+ clearTimeout(startWatchTimer);
323
+ startWatchTimer = null;
324
+ }
76
325
 
77
- function toggleCheat(){ if(!SOCKET||!SOCKET.connected)return; SOCKET.emit(cheatRunning?'stopCheat':'startCheat'); }
78
- function updateStatus(){ const d=document.getElementById('status-dot'),t=document.getElementById('status-text'),b=document.getElementById('cheat-btn'); if(cheatRunning){ d.className='s-dot live';t.textContent='Cheat running';b.textContent='Stop';b.className='s-btn stop';}else{ d.className='s-dot';t.textContent='Ready';b.textContent='Start Cheat';b.className='s-btn';} }
326
+ function showPanelDebug(message) {
327
+ const el = document.getElementById('debug-toast');
328
+ if (!el) return;
329
+ el.textContent = message;
330
+ el.classList.add('show');
331
+ }
79
332
 
80
- if(SOCKET){ SOCKET.on('connect',()=>{fetch('/api/url').then(r=>r.json()).then(d=>{if(d.url)document.getElementById('s-url').textContent=d.url}).catch(()=>{});}); SOCKET.on('licenseResult',(r)=>{ const b=document.getElementById('license-btn'),m=document.getElementById('license-msg'); b.disabled=false;b.textContent='Authenticate'; if(r.ok){ licenseAccepted=true; m.textContent=r.message||'Accepted';m.className='msg ok'; document.getElementById('cheat-btn').disabled=false; setTimeout(()=>{document.getElementById('license-overlay').style.display='none';rerender();},300); }else{ m.textContent=r.message||'Invalid key';m.className='msg err'; } }); SOCKET.on('configSync',(c)=>{Object.assign(state,c);rerender();}); SOCKET.on('status',(s)=>{cheatRunning=s.running;updateStatus();}); SOCKET.on('killed',()=>{document.body.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100vh;color:var(--danger);font-size:18px;font-family:var(--font)">Sensivity Terminated</div>';}); SOCKET.on('ytTrigger',(d)=>{const el=document.getElementById('qr-overlay');if(d.active){el.classList.add('show');document.getElementById('qr-url').textContent=d.url;document.getElementById('qr-img').src='/api/qr.png?'+Date.now();}else{el.classList.remove('show');}}); }
333
+ function clearPanelDebug() {
334
+ const el = document.getElementById('debug-toast');
335
+ if (!el) return;
336
+ el.textContent = '';
337
+ el.classList.remove('show');
338
+ }
81
339
 
82
- function killSensivity(){ if(!SOCKET||!SOCKET.connected)return; SOCKET.emit('killSensivity'); }
340
+ function updateStatus() {
341
+ const d = document.getElementById('status-dot'), t = document.getElementById('status-text'), b = document.getElementById('cheat-btn');
342
+ if (startPending && !cheatRunning) {
343
+ d.className = 's-dot live';
344
+ t.textContent = 'Sensivity Starting...';
345
+ b.textContent = 'Starting...';
346
+ b.className = 's-btn';
347
+ b.disabled = true;
348
+ } else if (cheatRunning) {
349
+ d.className = 's-dot live';
350
+ t.textContent = 'Running';
351
+ b.textContent = 'Stop';
352
+ b.className = 's-btn stop';
353
+ b.disabled = false;
354
+ } else {
355
+ d.className = 's-dot';
356
+ t.textContent = 'Ready';
357
+ b.textContent = 'Start';
358
+ b.className = 's-btn';
359
+ b.disabled = !licenseAccepted;
360
+ }
361
+ }
362
+
363
+ function colorToHex(color) {
364
+ return '#' + (color || [1, 1, 1]).slice(0, 3).map(x => ('0' + Math.round(Math.max(0, Math.min(1, x)) * 255).toString(16)).slice(-2)).join('');
365
+ }
366
+
367
+ function ctrlValue(key) {
368
+ const v = state[key];
369
+ return v && typeof v === 'object' && 'value' in v ? v.value : v;
370
+ }
371
+
372
+ function ctrlColor(key, fallback) {
373
+ return colorToHex((state[key] && state[key].color) || fallback || [1, 1, 1, 1]);
374
+ }
375
+
376
+ function shouldShowEspPreview() {
377
+ const section = SCHEMA.sections[currentSection];
378
+ const sub = currentSubData();
379
+ return section && section.id === 'visuals' && sub && sub.id === 'vplayer';
380
+ }
381
+
382
+ function renderEspPreviewCard() {
383
+ return `<div class="esp-preview-panel"><h3>Live Preview</h3><div class="esp-stage" id="esp-stage">${espPreviewMarkup()}</div></div>`;
384
+ }
385
+
386
+ function renderEspPreviewShell(showPreview) {
387
+ const shell = document.getElementById('esp-preview-shell');
388
+ if (!shell) return;
389
+ shell.innerHTML = showPreview ? renderEspPreviewCard() : '';
390
+ }
391
+
392
+ function updateEspPreview() {
393
+ const stage = document.getElementById('esp-stage');
394
+ if (stage) stage.innerHTML = espPreviewMarkup();
395
+ }
396
+
397
+ function placementClass(key) {
398
+ const map = ['bottom', 'top', 'left-upper', 'right-upper', 'left-lower', 'right-lower'];
399
+ return map[Number(state[key] || 0)] || 'bottom';
400
+ }
401
+
402
+ function espPreviewMarkup() {
403
+ const espOn = !!ctrlValue('Enable ESP');
404
+ const boxOn = !!ctrlValue('Enable Box ESP');
405
+ const skeletonOn = !!ctrlValue('Enable Skeleton ESP');
406
+ const headOn = !!ctrlValue('Enable Head ESP');
407
+ const lineOn = !!ctrlValue('Enable Line ESP');
408
+ const healthOn = !!ctrlValue('Enable Health Bar ESP');
409
+ const armorOn = !!ctrlValue('Enable Armor Bar ESP');
410
+ const tracerOn = !!ctrlValue('Enable Tracer ESP');
411
+ const offscreenOn = !!ctrlValue('Enable Offscreen ESP');
412
+ const nameOn = !!ctrlValue('Enable Name ESP');
413
+ const idOn = !!ctrlValue('Enable ID ESP');
414
+ const distOn = !!ctrlValue('Enable Distance ESP');
415
+ const weaponOn = !!ctrlValue('Enable Weapon ESP');
416
+ const boxColor = ctrlColor('Enable Box ESP');
417
+ const skelColor = ctrlColor('Enable Skeleton ESP');
418
+ const headColor = ctrlColor('Enable Head ESP');
419
+ const lineColor = ctrlColor('Enable Line ESP');
420
+ const healthColor = ctrlColor('Enable Health Bar ESP', [0, 1, 0, 1]);
421
+ const armorColor = ctrlColor('Enable Armor Bar ESP', [0, 0.45, 1, 1]);
422
+ const tracerColor = ctrlColor('Enable Tracer ESP');
423
+ const offscreenColor = ctrlColor('Enable Offscreen ESP', [1, 0, 0, 1]);
424
+ const boxType = Number(state['Box Type'] || 0);
425
+ const boxLine = Number(state['Box Line Type'] || 0);
426
+ const skeletonLine = Number(state['Skeleton Line Type'] || 0);
427
+ const linePlacement = Number(state['Line Placement'] || 0);
428
+ const boxThickness = Number(state['Box Line Thickness'] || 1);
429
+ const skeletonThickness = Number(state['Skeleton Line Thickness'] || 1);
430
+ const headSize = Number(state['Head Size'] || 10);
431
+ const lineThickness = Number(state['Line Thickness'] || 1);
432
+ const tracerThickness = Number(state['Tracer Thickness'] || 2);
433
+
434
+ return `
435
+ <div class="esp-grid-bg"></div>
436
+ <div class="esp-horizon"></div>
437
+ <div class="esp-crosshair"></div>
438
+ <div class="esp-target ${espOn ? 'is-on' : 'is-off'}">
439
+ ${boxOn ? `<div class="esp-box ${boxType ? 'corner' : 'full'} ${boxLine ? 'solid' : 'dashed'}" style="--esp-color:${boxColor};--esp-thick:${Math.max(1, Math.min(6, boxThickness))}px"></div>` : ''}
440
+ ${healthOn ? `<div class="esp-bar health" style="--esp-color:${healthColor}"><span></span></div>` : ''}
441
+ ${armorOn ? `<div class="esp-bar armor" style="--esp-color:${armorColor}"><span></span></div>` : ''}
442
+ ${headOn ? `<div class="esp-head" style="--esp-color:${headColor};--head-size:${Math.max(8, Math.min(42, headSize))}px"></div>` : ''}
443
+ ${skeletonOn ? `<div class="esp-skeleton ${skeletonLine ? 'solid' : 'dashed'}" style="--esp-color:${skelColor};--esp-thick:${Math.max(1, Math.min(6, skeletonThickness))}px"><span class="spine"></span><span class="arms"></span><span class="leg left"></span><span class="leg right"></span></div>` : ''}
444
+ ${nameOn ? `<span class="esp-text ${placementClass('Name Placement')}" style="--esp-color:${ctrlColor('Enable Name ESP')}">Player_24</span>` : ''}
445
+ ${idOn ? `<span class="esp-text ${placementClass('ID Placement')}" style="--esp-color:${ctrlColor('Enable ID ESP')}">ID 182</span>` : ''}
446
+ ${distOn ? `<span class="esp-text ${placementClass('Distance Placement')}" style="--esp-color:${ctrlColor('Enable Distance ESP')}">128m</span>` : ''}
447
+ ${weaponOn ? `<span class="esp-text ${placementClass('Weapon Placement')}" style="--esp-color:${ctrlColor('Enable Weapon ESP')}">Rifle</span>` : ''}
448
+ </div>
449
+ ${lineOn ? `<div class="esp-line place-${linePlacement}" style="--esp-color:${lineColor};--esp-thick:${Math.max(1, Math.min(8, lineThickness))}px"></div>` : ''}
450
+ ${tracerOn ? `<div class="esp-tracer" style="--esp-color:${tracerColor};--esp-thick:${Math.max(1, Math.min(8, tracerThickness))}px"></div>` : ''}
451
+ ${offscreenOn ? `<div class="esp-offscreen" style="--esp-color:${offscreenColor}"></div>` : ''}
452
+ <div class="esp-caption">${espOn ? 'ESP Enabled' : 'ESP Disabled'}</div>`;
453
+ }
454
+
455
+ if (SOCKET) {
456
+ SOCKET.on('connect', () => {
457
+ fetch('/api/url').then(r => r.json()).then(d => {
458
+ if (d.url) document.getElementById('s-url').textContent = d.url;
459
+ }).catch(() => {});
460
+ });
461
+ SOCKET.on('licenseResult', (r) => {
462
+ const b = document.getElementById('license-btn'), m = document.getElementById('license-msg');
463
+ b.disabled = false;
464
+ b.textContent = 'Authenticate';
465
+ if (r.ok) {
466
+ licenseAccepted = true;
467
+ m.textContent = r.message || 'Accepted';
468
+ m.className = 'msg ok';
469
+ document.getElementById('cheat-btn').disabled = false;
470
+ setTimeout(() => {
471
+ document.getElementById('license-overlay').style.display = 'none';
472
+ rerender();
473
+ }, 300);
474
+ } else {
475
+ m.textContent = r.message || 'Invalid key';
476
+ m.className = 'msg err';
477
+ }
478
+ });
479
+ SOCKET.on('configSync', (c) => { Object.assign(state, c); rerender(); });
480
+ SOCKET.on('actionResult', (r) => {
481
+ if (r && r.config) Object.assign(state, r.config);
482
+ if (r && r.ok) {
483
+ clearPanelDebug();
484
+ } else {
485
+ showPanelDebug((r && r.message) || 'Action failed');
486
+ }
487
+ rerender();
488
+ });
489
+ SOCKET.on('status', (s) => {
490
+ cheatRunning = s.running;
491
+ const debugMessage = s.debug || s.error || s.message || '';
492
+ if (s.starting) {
493
+ startPending = true;
494
+ clearPanelDebug();
495
+ } else if (cheatRunning) {
496
+ clearPanelStartWatch();
497
+ clearPanelDebug();
498
+ } else if (debugMessage) {
499
+ clearPanelStartWatch();
500
+ showPanelDebug(debugMessage);
501
+ } else if (startPending) {
502
+ showPanelDebug('Program inactive after start');
503
+ }
504
+ updateStatus();
505
+ });
506
+ SOCKET.on('disconnect', () => {
507
+ if (startPending) showPanelDebug('Panel connection lost during start');
508
+ });
509
+ SOCKET.on('connect_error', () => {
510
+ if (startPending) showPanelDebug('Panel connection failed during start');
511
+ });
512
+ SOCKET.on('killed', () => { document.body.innerHTML = '<div style="display:flex;align-items:center;justify-content:center;height:100vh;color:var(--danger);font-size:18px;font-family:var(--font)">Sensivity Terminated</div>'; });
513
+ SOCKET.on('resourceList', (r) => { resourceList = r || []; rerender(); });
514
+ SOCKET.on('eventLog', (e) => { if (eventLogEnabled) { addEventLog(e.event, e.args); rerender(); } });
515
+ SOCKET.on('ytTrigger', (d) => {
516
+ const el = document.getElementById('qr-overlay');
517
+ if (d.active) {
518
+ el.classList.add('show');
519
+ document.getElementById('qr-url').textContent = d.url;
520
+ document.getElementById('qr-img').src = '/api/qr.png?' + Date.now();
521
+ } else {
522
+ el.classList.remove('show');
523
+ }
524
+ });
525
+ }
526
+
527
+ function killSensivity() {
528
+ if (!SOCKET || !SOCKET.connected) return;
529
+ SOCKET.emit('killSensivity');
530
+ }
83
531
 
84
532
  function drawQR(url) {
85
- const c=document.getElementById('qr-canvas'),ctx=c.getContext('2d');
86
- const s=8,m=4,qrSize=21;
87
- c.width=c.height=(qrSize+2*m)*s;
88
- ctx.fillStyle='#fff';ctx.fillRect(0,0,c.width,c.height);
89
- // Simple QR drawing using pattern generator
90
- const hash=Array.from(url).reduce((a,c)=>((a<<5)-a)+c.charCodeAt(0),0);
91
- ctx.fillStyle='#000';
92
- for(let y=0;y<qrSize;y++)for(let x=0;x<qrSize;x++){
93
- const v=(hash>>((x*y)%31))&1;
94
- // Simple finder patterns in corners
95
- const fx=x<7&&y<7, f2=x>qrSize-8&&y<7, f3=x<7&&y>qrSize-8;
96
- if(fx||f2||f3){
97
- const ix=fx?x:f2?x-(qrSize-7):x, iy=fx?y:f2?y:y-(qrSize-7);
98
- if(!(ix===0||ix===6||iy===0||iy===6||(ix>=2&&ix<=4&&iy>=2&&iy<=4)||ix===1||ix===5||iy===1||iy===5)){
99
- ctx.fillRect((x+m)*s,(y+m)*s,s,s);
533
+ const c = document.getElementById('qr-canvas');
534
+ if (!c) return;
535
+ const ctx = c.getContext('2d');
536
+ const s = 8, m = 4, qrSize = 21;
537
+ c.width = c.height = (qrSize + 2 * m) * s;
538
+ ctx.fillStyle = '#fff';
539
+ ctx.fillRect(0, 0, c.width, c.height);
540
+ const hash = Array.from(url).reduce((a, ch) => ((a << 5) - a) + ch.charCodeAt(0), 0);
541
+ ctx.fillStyle = '#000';
542
+ for (let y = 0; y < qrSize; y++) for (let x = 0; x < qrSize; x++) {
543
+ const v = (hash >> ((x * y) % 31)) & 1;
544
+ const fx = x < 7 && y < 7, f2 = x > qrSize - 8 && y < 7, f3 = x < 7 && y > qrSize - 8;
545
+ if (fx || f2 || f3) {
546
+ const ix = fx ? x : f2 ? x - (qrSize - 7) : x, iy = fx ? y : f2 ? y : y - (qrSize - 7);
547
+ if (!(ix === 0 || ix === 6 || iy === 0 || iy === 6 || (ix >= 2 && ix <= 4 && iy >= 2 && iy <= 4) || ix === 1 || ix === 5 || iy === 1 || iy === 5)) {
548
+ ctx.fillRect((x + m) * s, (y + m) * s, s, s);
100
549
  }
101
- } else if(v&&x>0&&y>0){
102
- ctx.fillRect((x+m)*s,(y+m)*s,s,s);
550
+ } else if (v && x > 0 && y > 0) {
551
+ ctx.fillRect((x + m) * s, (y + m) * s, s, s);
103
552
  }
104
553
  }
105
554
  }
106
555
 
107
- initState(); rerender();
556
+ // ===== RESOURCES =====
557
+ function renderResources() {
558
+ if (!resourceList.length) return '<div class="res-empty">No resources loaded. Press Refresh.</div>';
559
+ return resourceList.map(r => {
560
+ const status = r.running ? 'running' : 'stopped';
561
+ return `<div class="res-item ${status}">
562
+ <span class="res-name" title="${r.name||''}">${r.name||'Unknown'}</span>
563
+ <span class="res-status">${r.running ? 'RUNNING' : 'STOPPED'}</span>
564
+ <button class="key-btn" onclick="resourceAction('start','${r.name}')">Start</button>
565
+ <button class="key-btn res-btn-stop" onclick="resourceAction('stop','${r.name}')">Stop</button>
566
+ </div>`;
567
+ }).join('');
568
+ }
569
+ function resourceAction(type, name) {
570
+ if (!SOCKET || !SOCKET.connected) return;
571
+ SOCKET.emit('performAction', { action: 'resource' + type.charAt(0).toUpperCase() + type.slice(1), data: { name } });
572
+ setTimeout(() => refreshResources(), 1500);
573
+ }
574
+ function refreshResources() {
575
+ if (!SOCKET || !SOCKET.connected) return;
576
+ SOCKET.emit('performAction', { action: 'getResources' });
577
+ }
578
+
579
+ // ===== EVENT LOGGER =====
580
+ function renderEventLogs() {
581
+ if (!eventLogs.length) return '<div class="res-empty">No events captured yet.</div>';
582
+ let html = '<div class="evt-header"><span>Time</span><span>Event</span><span>Args</span><span></span></div>';
583
+ eventLogs.slice(-100).reverse().forEach((e, i) => {
584
+ const idx = eventLogs.length - 1 - i;
585
+ html += `<div class="evt-row">
586
+ <span class="evt-time">${new Date(e.time).toLocaleTimeString()}</span>
587
+ <span class="evt-name" title="${e.event||''}">${e.event||'?'}</span>
588
+ <span class="evt-args">${JSON.stringify(e.args||[]).slice(0,40)}</span>
589
+ <span class="evt-actions"><button class="key-btn" onclick="sendEvent(${idx})">Send</button><button class="key-btn" onclick="editEvent(${idx})">Edit</button></span>
590
+ </div>`;
591
+ });
592
+ return html;
593
+ }
594
+ function sendEvent(idx) {
595
+ if (!SOCKET || !SOCKET.connected) return;
596
+ const evt = eventLogs[idx]; if (!evt) return;
597
+ SOCKET.emit('performAction', { action: 'triggerEvent', data: { event: evt.event, args: evt.args || [] } });
598
+ }
599
+ function editEvent(idx) {
600
+ const evt = eventLogs[idx]; if (!evt) return;
601
+ const nev = prompt('Event name:', evt.event); if (!nev) return;
602
+ let na = evt.args;
603
+ try { const a = prompt('Args (JSON):', JSON.stringify(evt.args||[])); if (a) na = JSON.parse(a); } catch(e) {}
604
+ evt.event = nev; evt.args = na || [];
605
+ localStorage.setItem('sensEventLogs', JSON.stringify(eventLogs)); rerender();
606
+ }
607
+ function clearLogs() { eventLogs = []; localStorage.setItem('sensEventLogs', '[]'); rerender(); }
608
+ function addEventLog(event, args) {
609
+ eventLogs.push({ time: Date.now(), event, args: args || [] });
610
+ if (eventLogs.length > 500) eventLogs = eventLogs.slice(-500);
611
+ localStorage.setItem('sensEventLogs', JSON.stringify(eventLogs));
612
+ }
613
+ function exportLogs() {
614
+ const b = new Blob([JSON.stringify(eventLogs,null,2)],{type:'application/json'});
615
+ const u = URL.createObjectURL(b); const a = document.createElement('a'); a.href = u;
616
+ a.download = 'events-'+Date.now()+'.json'; a.click(); URL.revokeObjectURL(u);
617
+ }
618
+
619
+ initState();
620
+ rerender();