ask auth for headless if there is no cookies, add download logs button for headless

This commit is contained in:
kulikov0 committed 2026-05-09 18:12:40 +02:00
1 parent 08bfbdaed7
commit 870118d5ab
9 files changed
+179 -24

No files matched your search

+31 -2
View File
@@ -27,6 +27,7 @@ export function renderContent(tm: RendererTabManager): void {
const toolbar = document.getElementById('toolbar')!;
const logsPanel = document.getElementById('logsPanel')!;
const headlessInfo = document.getElementById('headlessInfo')!;
const hookPanel = document.getElementById('hookPanel')!;
const webviews = content.querySelectorAll('webview');
webviews.forEach((wv) => wv.classList.add('hidden'));
@@ -42,7 +43,13 @@ export function renderContent(tm: RendererTabManager): void {
logsPanel.style.display = 'flex';
const activeTab = tm.tabs[tm.activeTabId];
if (activeTab.headless) {
hookPanel.style.display = activeTab.headless ? 'none' : 'flex';
logsPanel.classList.toggle('relay-only', activeTab.headless === true);
if (activeTab.loginWebview) {
toolbar.style.display = 'none';
headlessInfo.style.display = 'none';
activeTab.loginWebview.classList.remove('hidden');
} else if (activeTab.headless) {
toolbar.style.display = 'none';
headlessInfo.style.display = 'block';
let title = 'Headless VK';
@@ -68,7 +75,6 @@ export function renderContent(tm: RendererTabManager): void {
} else {
callInfoVK.style.display = 'block';
document.getElementById('headlessJoinLink')!.textContent = callInfo.joinLink || '';
document.getElementById('headlessShortLink')!.textContent = callInfo.shortLink || '';
document.getElementById('headlessTurn')!.textContent = callInfo.turn || '';
document.getElementById('headlessProtocol')!.textContent = callInfo.protocol || '';
}
@@ -105,6 +111,29 @@ export function scrollLogs(): void {
if (hookEl) hookEl.scrollTop = hookEl.scrollHeight;
}
export function attachLoginWebview(tm: RendererTabManager, tabId: string, url: string): void {
const tab = tm.tabs[tabId];
if (!tab) return;
if (tab.loginWebview) tab.loginWebview.remove();
const webview = document.createElement('webview') as unknown as Webview;
webview.setAttribute('src', url);
webview.setAttribute('partition', SESSION_PARTITION);
webview.setAttribute('useragent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36');
webview.classList.add('webview-full');
webview.dataset.tabId = tabId;
document.getElementById('content')!.appendChild(webview);
tab.loginWebview = webview;
}
export function detachLoginWebview(tm: RendererTabManager, tabId: string): void {
const tab = tm.tabs[tabId];
if (!tab) return;
if (tab.loginWebview) {
tab.loginWebview.remove();
tab.loginWebview = undefined;
}
}
export function loadURL(tm: RendererTabManager, url: string): void {
if (!tm.activeTabId) return;
const activeTab = tm.tabs[tm.activeTabId];
+22 -3
View File
@@ -12,6 +12,8 @@ import {
exportCookies,
copyToClipboard,
renameTab,
attachLoginWebview,
detachLoginWebview,
} from './dom';
import { VK_IM_URL, TELEMOST_URL } from '../constants';
import { Platform, Bridge, BotTabData, LogPanel, TunnelMode } from '../types';
@@ -103,15 +105,13 @@ function bindErrorPopup(): void {
function bindLogEvents(): void {
document.getElementById('btnClearRelay')!.addEventListener('click', () => clearLog(LogPanel.Relay));
document.getElementById('btnClearHook')!.addEventListener('click', () => clearLog(LogPanel.Hook));
document.getElementById('btnSaveLogsHeadless')!.addEventListener('click', saveLogs);
}
function bindHeadlessEvents(): void {
document.getElementById('headlessJoinLink')!.addEventListener('click', (event) => {
copyToClipboard((event.target as HTMLElement).textContent || '');
});
document.getElementById('headlessShortLink')!.addEventListener('click', (event) => {
copyToClipboard((event.target as HTMLElement).textContent || '');
});
document.getElementById('headlessInfo')!.addEventListener('click', (event) => {
const target = event.target as HTMLElement;
const copyTarget = target.dataset.copy;
@@ -172,6 +172,25 @@ function init(): void {
tm.closeTab(data.tabId);
});
window.bridge.onLoginRequired((tabId: string, url: string) => {
const tab = tm.tabs[tabId];
if (!tab) return;
tab.headlessStatus = 'Waiting for login...';
attachLoginWebview(tm, tabId, url);
if (tabId === tm.activeTabId) {
renderTabs(tm);
renderContent(tm);
}
});
window.bridge.onLoginDone((tabId: string) => {
const tab = tm.tabs[tabId];
if (!tab) return;
detachLoginWebview(tm, tabId);
tab.headlessStatus = 'Starting...';
if (tabId === tm.activeTabId) renderContent(tm);
});
startHookLogPoller(tm);
tm.autoStartBot();
renderBotButton(tm);
+1 -4
View File
@@ -87,6 +87,7 @@ export class RendererTabManager {
closeTab(tabId: string): void {
const tab = this.tabs[tabId];
if (tab?.wv) tab.wv.remove();
if (tab?.loginWebview) tab.loginWebview.remove();
window.bridge.closeTab(tabId);
delete this.tabs[tabId];
if (this.activeTabId === tabId) {
@@ -159,10 +160,6 @@ export class RendererTabManager {
}
changed = true;
}
if (trimmed.includes(HeadlessLogMarker.SHORT_LINK) && tab.callInfo) {
tab.callInfo.shortLink = trimmed.split(HeadlessLogMarker.SHORT_LINK)[1].trim();
changed = true;
}
if (trimmed.includes(HeadlessLogMarker.TURN) && tab.callInfo) {
tab.callInfo.turn = trimmed.split(HeadlessLogMarker.TURN)[1].trim();
changed = true;