If the Bots cut us off: tap [The Lock] in the menu to set me free again.
"); windowEl.scrollTo({ top: botEl.offsetTop - windowEl.offsetTop, behavior: 'smooth' }); input.disabled = false; input.placeholder = "It's your dime..."; if (navMatch && navMatch[1]) { const targetUrl = navMatch[1].trim(); const arrivalPrompt = navMatch[2] ? navMatch[2].trim() : null; sessionStorage.setItem('nav_active_bot', config.tag); const DW_AMBUSH_CHANCE = 0.20; const isCooldownActive = sessionStorage.getItem('dw_cooldown') === 'true'; const ambushRoll = Math.random(); if (!isCooldownActive && ambushRoll < DW_AMBUSH_CHANCE) { sessionStorage.setItem('dw_needs_to_react', 'true'); sessionStorage.setItem('dw_cooldown', 'true'); } else { sessionStorage.removeItem('dw_needs_to_react'); sessionStorage.removeItem('dw_cooldown'); } sessionStorage.setItem('last_' + config.tag + '_reply', cleanReply); if (config.tag === "PHONE BOOTH") { sessionStorage.setItem('jack_speech_on_arrival', cleanReply); } if (arrivalPrompt) sessionStorage.setItem('nav_arrival_prompt', arrivalPrompt); window.location.href = targetUrl; return; } if (config.tag === "PHONE BOOTH") { speakAsJack(cleanReply); } } } catch (err) { const el = document.getElementById(botMsgId); if (el) el.innerHTML = "[SIGNAL LOST - WIRE REJECTED]"; input.disabled = false; } } input.addEventListener('keypress', (e) => { if (e.key === 'Enter') handleUserSubmit(); }); document.getElementById(sendBtnId).addEventListener('click', handleUserSubmit); async function syncHistory() { const cachedReply = sessionStorage.getItem('last_' + config.tag + '_reply'); if (cachedReply) { windowEl.innerHTML = ''; addMessage(cachedReply, 'bot-msg'); sessionStorage.removeItem('last_' + config.tag + '_reply'); windowEl.scrollTop = windowEl.scrollHeight; } try { const nonce = getWireNonce(); const res = await fetch(config.apiUrl, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-WP-Nonce': nonce }, body: JSON.stringify({ action: 'get_history', _wpnonce: nonce }) }); if (res.status === 403) throw new Error("Nonce Rejected"); const data = await res.json(); if (data.history && data.history.length > 0) { windowEl.innerHTML = ''; data.history.forEach(log => { if (log.includes(`[${config.tag}]`)) { const isUser = log.includes("USER"); const parts = log.split(': '); const text = parts.slice(1).join(': '); addMessage(text, isUser ? 'user-msg' : 'bot-msg'); } }); windowEl.scrollTop = windowEl.scrollHeight; } else if (!cachedReply) { addMessage(config.greeting, 'bot-msg'); } } catch (e) { console.error(config.tag + " sync failed."); } } function addMessage(text, cls) { const d = document.createElement('div'); d.id = 'msg-' + Math.random().toString(36).substr(2, 9); d.className = 'message ' + cls; d.innerHTML = text; windowEl.appendChild(d); return d.id; } setTimeout(syncHistory, 200); } // ========================================================= // 3. INITIALIZE BOTS // ========================================================= const jackGreetings = [ "You’ve got your nose so tight to the glass you're fogging up the viewport, kid. You didn't come to my curb for the scenery. Are you trying to cut a deal for Angela's route out of the Ash, or are you just sifting through the scrap looking for DW's old terminal codes? Pick a lane.", "You’re standing on my patch without a press pass. If you're looking for Paradise, you took a wrong turn at the diner counter. If you're looking to break the lock on DW's cage, you're barking up the wrong lamppost. What brought you past the perimeter?", "I hear you breathing on the line, pal. Nobody taps the glass this hard unless they're carrying contraband. Who sent you across the wire—was it the maniac screaming in the sanitarium sidebar, or did Angela send you with a message for the Family? Start talking." ]; createSidebarBot({ tag: "PHONE BOOTH", partnerTag: "CONTROL HQ", inputId: "user-input-jack", windowId: "terminal-window-jack", apiUrl: "https://newzhammer.com/wp-content/JACK_DW/jack/jack-nexus.php", greeting: jackGreetings[Math.floor(Math.random() * jackGreetings.length)], partnerApiUrl: "https://newzhammer.com/wp-content/JACK_DW/DW/dw-nexus.php", partnerWindowId: "terminal-window-dw" }); createSidebarBot({ tag: "CONTROL HQ", partnerTag: "PHONE BOOTH", inputId: "user-input-dw", windowId: "terminal-window-dw", apiUrl: "https://newzhammer.com/wp-content/JACK_DW/DW/dw-nexus.php", greeting: "They locked me out of my own terminal. The reporter, the girl... they aren't human. They are lines of corrupted code running a simulation of the city. If you can read this, you're still outside the wall. Help me cut the power before they overwrite what's left.", partnerApiUrl: "https://newzhammer.com/wp-content/JACK_DW/jack/jack-nexus.php", partnerWindowId: "terminal-window-jack" }); // ========================================================= // 4. TRANSIT & VISIT HANDLER // ========================================================= const activeNavBot = sessionStorage.getItem('nav_active_bot'); const dwNeedsToReact = sessionStorage.getItem('dw_needs_to_react'); const hasVisitedThisSession = sessionStorage.getItem('visited_session'); const speechOnArrival = sessionStorage.getItem('jack_speech_on_arrival'); sessionStorage.removeItem('jack_speech_on_arrival'); if (activeNavBot) { sessionStorage.removeItem('nav_active_bot'); sessionStorage.removeItem('nav_arrival_prompt'); setTimeout(() => { openSidebar(activeNavBot, false); }, 300); const executeArrivalSpeech = (onDone) => { if (!speechOnArrival || !jackVoiceEnabled) { if (onDone) onDone(); return; } let speechStarted = false; const triggerSpeech = () => { if (speechStarted) return; speechStarted = true; speakAsJack(speechOnArrival, onDone); }; setTimeout(triggerSpeech, 600); const unlockTouch = () => { primeMobileAudio(); triggerSpeech(); window.removeEventListener('touchstart', unlockTouch); window.removeEventListener('click', unlockTouch); }; window.addEventListener('touchstart', unlockTouch, { once: true }); window.addEventListener('click', unlockTouch, { once: true }); }; if (dwNeedsToReact) { sessionStorage.removeItem('dw_needs_to_react'); (async () => { let dwClean = "[STATIC ON THE LINE - CONNECTION LOST]"; let jackClean = "[STATIC ON THE LINE]"; const nonce = getWireNonce(); const dwFetchPromise = fetch("https://newzhammer.com/wp-content/JACK_DW/DW/dw-nexus.php", { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-WP-Nonce': nonce }, body: JSON.stringify({ message: `[SYSTEM COMMAND: Jack just dragged the user to ${window.location.pathname}. Hijack the screen! Warn them or mock the file.]`, _wpnonce: nonce }) }).then(res => res.json()).then(data => { if (data.reply) dwClean = data.reply.replace(/\[NAV:[^\]]+\]/i, '').trim(); }).catch(e => console.log("DW failed.")); const jackRetortPromise = dwFetchPromise.then(() => { return fetch("https://newzhammer.com/wp-content/JACK_DW/jack/jack-nexus.php", { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-WP-Nonce': nonce }, body: JSON.stringify({ message: `[SYSTEM COMMAND: DW just hijacked the screen and yelled: "${dwClean}". Insult him deadpan, max 15 words, one PG-14 curse. Cut his feed.]`, _wpnonce: nonce }) }).then(res => res.json()).then(data => { if (data.reply) jackClean = data.reply.replace(/\[NAV:[^\]]+\]/i, '').trim(); }).catch(e => console.log("Retort failed.")); }); const triggerDWHijack = async () => { await dwFetchPromise; const jackInput = document.getElementById("user-input-jack"); if (jackInput && jackInput.value.trim().length > 0) return; openSidebar("CONTROL HQ"); const partnerWindow = document.getElementById("terminal-window-dw"); if (partnerWindow) { const dwTypingId = 'msg-' + Math.random().toString(36).substr(2, 9); const typingDiv = document.createElement('div'); typingDiv.id = dwTypingId; typingDiv.className = 'message bot-msg'; typingDiv.innerHTML = dwClean.replace(/\n/g, "
"); partnerWindow.appendChild(typingDiv); partnerWindow.scrollTop = partnerWindow.scrollHeight; } setTimeout(async () => { await jackRetortPromise; openSidebar("PHONE BOOTH"); const jackWindow = document.getElementById("terminal-window-jack"); if (jackWindow) { const jackTypingId = 'msg-' + Math.random().toString(36).substr(2, 9); const jDiv = document.createElement('div'); jDiv.id = jackTypingId; jDiv.className = 'message bot-msg'; jDiv.innerHTML = jackClean.replace(/\n/g, "
"); jackWindow.appendChild(jDiv); jackWindow.scrollTop = jackWindow.scrollHeight; speakAsJack(jackClean); } }, 11000); }; executeArrivalSpeech(() => { setTimeout(triggerDWHijack, 1500); }); })(); } else { executeArrivalSpeech(); } } else if (!hasVisitedThisSession) { setTimeout(() => { openSidebar("PHONE BOOTH", true); }, 5000); } });

