save calls in creator app
This commit is contained in:
1 parent
d13bdc9058
commit
611739af9e
7 files changed
+318
-11
No files matched your search
+12
-6
@@ -9,8 +9,9 @@
|
||||
<div class="tab-add" data-action="add-tab" title="New tab">+</div>
|
||||
</div>
|
||||
<div class="tab-bar-actions">
|
||||
<div class="tab-action-btn" id="btnSavedCalls" title="Saved calls from earlier sessions">Saved</div>
|
||||
<div class="tab-action-btn" id="btnExportCookies" title="Export all cookies to cookies.zip for headless mode">Export Cookies</div>
|
||||
<div class="tab-action-btn settings" id="btnSettings" title="Settings">Settings</div>
|
||||
<div class="tab-action-btn" id="btnSettings" title="Settings">Settings</div>
|
||||
<div class="tab-action-btn bot" id="tabBot">Bot: Off</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -35,6 +36,11 @@
|
||||
<h1>Whitelist Bypass - Creator</h1>
|
||||
<p>Click + to add a tab</p>
|
||||
</div>
|
||||
<div class="saved-calls" id="savedCallsPanel">
|
||||
<div class="saved-calls-title">Saved calls</div>
|
||||
<div class="saved-calls-empty" id="savedCallsEmpty">No saved calls yet. Start a call and click the star next to its join link.</div>
|
||||
<div class="saved-calls-list" id="savedCallsList"></div>
|
||||
</div>
|
||||
<div class="headless-info" id="headlessInfo">
|
||||
<div class="headless-title" id="headlessTitle">Headless</div>
|
||||
<div class="headless-start" id="headlessStart">
|
||||
@@ -63,22 +69,22 @@
|
||||
</div>
|
||||
<div class="headless-status" id="headlessStatus">Starting...</div>
|
||||
<div class="headless-call-info" id="headlessCallInfo">
|
||||
<div class="headless-row"><span class="headless-label">Join link:</span> <a id="headlessJoinLink" href="#" class="headless-link"></a><img class="headless-copy" src="resources/icons8-copy-50.png" data-copy="headlessJoinLink" title="Copy"></div>
|
||||
<div class="headless-row"><span class="headless-label">Join link:</span> <a id="headlessJoinLink" href="#" class="headless-link"></a><img class="headless-copy" src="resources/icons8-copy-50.png" data-copy="headlessJoinLink" title="Copy"><span class="headless-save" data-action="save-call" title="Save this call"></span></div>
|
||||
<div class="headless-row"><span class="headless-label">TURN:</span> <span id="headlessTurn"></span></div>
|
||||
<div class="headless-row"><span class="headless-label">Protocol:</span> <span id="headlessProtocol"></span></div>
|
||||
</div>
|
||||
<div class="headless-call-info" id="headlessCallInfoTM">
|
||||
<div class="headless-row"><span class="headless-label">Join link:</span> <a id="headlessTMJoinLink" href="#" class="headless-link"></a><img class="headless-copy" src="resources/icons8-copy-50.png" data-copy="headlessTMJoinLink" title="Copy"></div>
|
||||
<div class="headless-row"><span class="headless-label">Join link:</span> <a id="headlessTMJoinLink" href="#" class="headless-link"></a><img class="headless-copy" src="resources/icons8-copy-50.png" data-copy="headlessTMJoinLink" title="Copy"><span class="headless-save" data-action="save-call" title="Save this call"></span></div>
|
||||
<div class="headless-row"><span class="headless-label">Protocol:</span> <span id="headlessTMProtocol"></span></div>
|
||||
</div>
|
||||
<div class="headless-call-info" id="headlessCallInfoWB">
|
||||
<div class="headless-row"><span class="headless-label">Join link:</span> <a id="headlessWBJoinLink" href="#" class="headless-link"></a><img class="headless-copy" src="resources/icons8-copy-50.png" data-copy="headlessWBJoinLink" title="Copy"></div>
|
||||
<div class="headless-row"><span class="headless-label">Join link:</span> <a id="headlessWBJoinLink" href="#" class="headless-link"></a><img class="headless-copy" src="resources/icons8-copy-50.png" data-copy="headlessWBJoinLink" title="Copy"><span class="headless-save" data-action="save-call" title="Save this call"></span></div>
|
||||
</div>
|
||||
<div class="headless-call-info" id="headlessCallInfoDion">
|
||||
<div class="headless-row"><span class="headless-label">Join link:</span> <a id="headlessDionJoinLink" href="#" class="headless-link"></a><img class="headless-copy" src="resources/icons8-copy-50.png" data-copy="headlessDionJoinLink" title="Copy"></div>
|
||||
<div class="headless-row"><span class="headless-label">Join link:</span> <a id="headlessDionJoinLink" href="#" class="headless-link"></a><img class="headless-copy" src="resources/icons8-copy-50.png" data-copy="headlessDionJoinLink" title="Copy"><span class="headless-save" data-action="save-call" title="Save this call"></span></div>
|
||||
</div>
|
||||
<div class="headless-call-info" id="headlessCallInfoBitrix">
|
||||
<div class="headless-row"><span class="headless-label">Join link:</span> <a id="headlessBitrixJoinLink" href="#" class="headless-link"></a><img class="headless-copy" src="resources/icons8-copy-50.png" data-copy="headlessBitrixJoinLink" title="Copy"></div>
|
||||
<div class="headless-row"><span class="headless-label">Join link:</span> <a id="headlessBitrixJoinLink" href="#" class="headless-link"></a><img class="headless-copy" src="resources/icons8-copy-50.png" data-copy="headlessBitrixJoinLink" title="Copy"><span class="headless-save" data-action="save-call" title="Save this call"></span></div>
|
||||
</div>
|
||||
<div class="headless-qr" id="headlessQrWrap" style="display:none">
|
||||
<img id="headlessQr" alt="Join link QR code">
|
||||
|
||||
@@ -8,6 +8,8 @@ export const CALL_CREATOR_INJECT_DELAY_MS = 1000;
|
||||
export const BOT_POLL_RETRY_DELAY_MS = 1000;
|
||||
export const BOT_POLL_WAIT_SECONDS = 25;
|
||||
|
||||
export const MAX_SAVED_CALLS = 50;
|
||||
|
||||
export const MAX_LOG_CHARS = 400000;
|
||||
export const LOG_TRIM_KEEP_CHARS = 200000;
|
||||
export const HOOK_LOG_BUFFER_LIMIT = 500;
|
||||
|
||||
@@ -15,8 +15,9 @@ import {
|
||||
attachLoginWebview,
|
||||
detachLoginWebview,
|
||||
} from './dom';
|
||||
import { SavedCallsView } from './saved-calls';
|
||||
import { VK_IM_URL, TELEMOST_URL } from '../constants';
|
||||
import { Platform, Bridge, BotTabData, LogPanel, TunnelMode, HeadlessMode } from '../types';
|
||||
import { Platform, Bridge, BotTabData, LogPanel, TunnelMode, HeadlessMode, SavedCall } from '../types';
|
||||
|
||||
declare const window: Window & { bridge: Bridge };
|
||||
|
||||
@@ -24,8 +25,11 @@ const tm = new RendererTabManager(() => {
|
||||
renderTabs(tm);
|
||||
renderContent(tm);
|
||||
renderBotButton(tm);
|
||||
renderSaveStars();
|
||||
});
|
||||
|
||||
const savedCalls = new SavedCallsView((call: SavedCall) => tm.startSavedCall(call));
|
||||
|
||||
function bindTabBarEvents(): void {
|
||||
document.getElementById('tabBar')!.addEventListener('click', (event) => {
|
||||
const target = event.target as HTMLElement;
|
||||
@@ -34,6 +38,7 @@ function bindTabBarEvents(): void {
|
||||
const tabId = tabEl?.dataset.tabId;
|
||||
|
||||
if (action === 'add-tab') {
|
||||
savedCalls.hide();
|
||||
tm.createTab();
|
||||
return;
|
||||
}
|
||||
@@ -48,6 +53,7 @@ function bindTabBarEvents(): void {
|
||||
return;
|
||||
}
|
||||
if (tabId) {
|
||||
savedCalls.hide();
|
||||
tm.selectTab(tabId);
|
||||
}
|
||||
});
|
||||
@@ -178,6 +184,7 @@ function bindHeadlessEvents(): void {
|
||||
const sourceEl = document.getElementById(copyTarget);
|
||||
if (sourceEl) copyToClipboard(sourceEl.textContent || '');
|
||||
}
|
||||
if (target.dataset.action === 'save-call') toggleActiveCallSaved();
|
||||
});
|
||||
document.getElementById('btnHeadlessCreate')!.addEventListener('click', () => {
|
||||
clearHeadlessJoinError();
|
||||
@@ -201,6 +208,28 @@ function bindHeadlessEvents(): void {
|
||||
});
|
||||
}
|
||||
|
||||
function toggleActiveCallSaved(): void {
|
||||
const tab = tm.getActiveTab();
|
||||
const joinLink = tab?.callInfo?.joinLink;
|
||||
if (!tab || !tab.platform || !joinLink) return;
|
||||
if (savedCalls.has(tab.platform, joinLink)) {
|
||||
savedCalls.remove(joinLink);
|
||||
} else {
|
||||
savedCalls.add(tab.platform, joinLink, tm.getTabLabel(tab));
|
||||
}
|
||||
renderSaveStars();
|
||||
}
|
||||
|
||||
function renderSaveStars(): void {
|
||||
const tab = tm.getActiveTab();
|
||||
const joinLink = tab?.callInfo?.joinLink;
|
||||
const saved = !!tab?.platform && !!joinLink && savedCalls.has(tab.platform, joinLink);
|
||||
document.querySelectorAll('.headless-save').forEach((star) => {
|
||||
star.classList.toggle('saved', saved);
|
||||
star.setAttribute('title', saved ? 'Saved, click to forget' : 'Save this call');
|
||||
});
|
||||
}
|
||||
|
||||
function showHeadlessJoinError(msg: string): void {
|
||||
const errEl = document.getElementById('headlessStartError')!;
|
||||
const input = document.getElementById('headlessStartTarget') as HTMLInputElement;
|
||||
@@ -253,6 +282,7 @@ function init(): void {
|
||||
bindErrorPopup();
|
||||
bindLogEvents();
|
||||
bindHeadlessEvents();
|
||||
savedCalls.bindEvents();
|
||||
|
||||
window.bridge.setUpstreamProxy(tm.upstreamProxy);
|
||||
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
import { Platform, SavedCall } from '../types';
|
||||
import { MAX_SAVED_CALLS } from '../constants';
|
||||
|
||||
const STORAGE_KEY = 'savedCalls';
|
||||
const OPEN_CLASS = 'saved-calls-open';
|
||||
|
||||
const PLATFORM_TITLES: Record<Platform, string> = {
|
||||
[Platform.VK]: 'VK',
|
||||
[Platform.Telemost]: 'Telemost',
|
||||
[Platform.WBStream]: 'WBStream',
|
||||
[Platform.Dion]: 'DION',
|
||||
[Platform.Bitrix]: 'Bitrix',
|
||||
};
|
||||
|
||||
export class SavedCallsView {
|
||||
private calls: SavedCall[];
|
||||
private open = false;
|
||||
|
||||
constructor(private onJoin: (call: SavedCall) => void) {
|
||||
this.calls = this.load();
|
||||
}
|
||||
|
||||
bindEvents(): void {
|
||||
document.getElementById('btnSavedCalls')!.addEventListener('click', () => this.toggle());
|
||||
document.getElementById('savedCallsList')!.addEventListener('click', (event) => {
|
||||
const target = event.target as HTMLElement;
|
||||
const action = target.dataset.action;
|
||||
const row = target.closest('[data-saved-target]') as HTMLElement | null;
|
||||
const savedTarget = row?.dataset.savedTarget;
|
||||
if (!savedTarget) return;
|
||||
if (action === 'join-saved') this.join(savedTarget);
|
||||
if (action === 'remove-saved') this.remove(savedTarget);
|
||||
});
|
||||
}
|
||||
|
||||
isOpen(): boolean {
|
||||
return this.open;
|
||||
}
|
||||
|
||||
show(): void {
|
||||
this.open = true;
|
||||
document.body.classList.add(OPEN_CLASS);
|
||||
this.render();
|
||||
}
|
||||
|
||||
hide(): void {
|
||||
this.open = false;
|
||||
document.body.classList.remove(OPEN_CLASS);
|
||||
}
|
||||
|
||||
has(platform: Platform, target: string): boolean {
|
||||
const trimmed = target.trim();
|
||||
return this.calls.some((entry) => entry.platform === platform && entry.target === trimmed);
|
||||
}
|
||||
|
||||
remove(target: string): void {
|
||||
this.calls = this.calls.filter((entry) => entry.target !== target);
|
||||
this.persist();
|
||||
if (this.open) this.render();
|
||||
}
|
||||
|
||||
add(platform: Platform, target: string, name: string): SavedCall | null {
|
||||
const trimmed = target.trim();
|
||||
if (!trimmed) return null;
|
||||
const call: SavedCall = { platform, target: trimmed, name, savedAt: Date.now() };
|
||||
const existing = this.calls.findIndex(
|
||||
(entry) => entry.platform === platform && entry.target === trimmed,
|
||||
);
|
||||
if (existing !== -1) {
|
||||
this.calls[existing] = call;
|
||||
} else {
|
||||
this.calls.unshift(call);
|
||||
if (this.calls.length > MAX_SAVED_CALLS) this.calls = this.calls.slice(0, MAX_SAVED_CALLS);
|
||||
}
|
||||
this.persist();
|
||||
if (this.open) this.render();
|
||||
return call;
|
||||
}
|
||||
|
||||
private toggle(): void {
|
||||
if (this.open) {
|
||||
this.hide();
|
||||
} else {
|
||||
this.show();
|
||||
}
|
||||
}
|
||||
|
||||
private join(target: string): void {
|
||||
const call = this.calls.find((entry) => entry.target === target);
|
||||
if (!call) return;
|
||||
this.hide();
|
||||
this.onJoin(call);
|
||||
}
|
||||
|
||||
private render(): void {
|
||||
const list = document.getElementById('savedCallsList')!;
|
||||
const empty = document.getElementById('savedCallsEmpty')!;
|
||||
empty.style.display = this.calls.length === 0 ? 'block' : 'none';
|
||||
list.innerHTML = this.calls
|
||||
.map((call) => {
|
||||
const target = escapeHtml(call.target);
|
||||
return (
|
||||
`<div class="saved-call" data-saved-target="${target}">` +
|
||||
`<span class="saved-call-platform">${escapeHtml(PLATFORM_TITLES[call.platform])}</span>` +
|
||||
`<div class="saved-call-body">` +
|
||||
`<div class="saved-call-name">${escapeHtml(call.name)}</div>` +
|
||||
`<div class="saved-call-link">${target}</div>` +
|
||||
'</div>' +
|
||||
`<button class="saved-call-join" data-action="join-saved">Join</button>` +
|
||||
`<span class="saved-call-remove" data-action="remove-saved" title="Forget this call">✕</span>` +
|
||||
'</div>'
|
||||
);
|
||||
})
|
||||
.join('');
|
||||
}
|
||||
|
||||
private load(): SavedCall[] {
|
||||
const stored = localStorage.getItem(STORAGE_KEY);
|
||||
if (!stored) return [];
|
||||
try {
|
||||
const parsed = JSON.parse(stored);
|
||||
return Array.isArray(parsed) ? parsed : [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private persist(): void {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(this.calls));
|
||||
}
|
||||
}
|
||||
|
||||
function escapeHtml(str: string): string {
|
||||
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
Bridge,
|
||||
HeadlessMode,
|
||||
HeadlessStartArgs,
|
||||
SavedCall,
|
||||
} from '../types';
|
||||
import { HeadlessLogMarker } from '../constants';
|
||||
import { appendLogText, appendLogElement, trimLogText } from './log-buffer';
|
||||
@@ -257,6 +258,17 @@ export class RendererTabManager {
|
||||
window.bridge.setDebugLogging(this.debugLogging);
|
||||
}
|
||||
|
||||
startSavedCall(call: SavedCall): void {
|
||||
this.createTab();
|
||||
this.switchToHeadless(call.platform);
|
||||
const tab = this.getActiveTab();
|
||||
if (!tab) return;
|
||||
tab.name = call.name;
|
||||
tab.headlessStartTarget = call.target;
|
||||
tab.joinedByLink = true;
|
||||
this.startHeadlessCall({ mode: HeadlessMode.Join, target: call.target });
|
||||
}
|
||||
|
||||
toggleBot(): void {
|
||||
if (!this.botSettings.token || !this.botSettings.groupId) return;
|
||||
this.botRunning = !this.botRunning;
|
||||
|
||||
@@ -117,6 +117,13 @@ export interface CallInfo {
|
||||
protocol?: string;
|
||||
}
|
||||
|
||||
export interface SavedCall {
|
||||
platform: Platform;
|
||||
target: string;
|
||||
name: string;
|
||||
savedAt: number;
|
||||
}
|
||||
|
||||
export enum HeadlessMode {
|
||||
Create = 'create',
|
||||
Join = 'join',
|
||||
|
||||
+119
-4
@@ -111,10 +111,6 @@ body {
|
||||
color: #e0e0e0;
|
||||
}
|
||||
|
||||
.tab-action-btn.settings {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.tab-action-btn.bot {
|
||||
font-weight: 500;
|
||||
}
|
||||
@@ -667,3 +663,122 @@ body {
|
||||
cursor: text;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.headless-save {
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-left: 6px;
|
||||
cursor: pointer;
|
||||
vertical-align: middle;
|
||||
background-color: #888;
|
||||
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z'/%3E%3C/svg%3E") center / contain no-repeat;
|
||||
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z'/%3E%3C/svg%3E") center / contain no-repeat;
|
||||
}
|
||||
|
||||
.headless-save:hover {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
.headless-save.saved {
|
||||
background-color: #4fc3f7;
|
||||
}
|
||||
|
||||
.saved-calls {
|
||||
display: none;
|
||||
padding: 24px;
|
||||
color: #e0e0e0;
|
||||
font-family: monospace;
|
||||
font-size: 14px;
|
||||
overflow-y: auto;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.saved-calls-title {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.saved-calls-empty {
|
||||
color: #888;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.saved-calls-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.saved-call {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
border: 1px solid #333;
|
||||
border-radius: 8px;
|
||||
background: #1e1e1e;
|
||||
padding: 12px 16px;
|
||||
}
|
||||
|
||||
.saved-call-platform {
|
||||
color: #888;
|
||||
font-size: 12px;
|
||||
width: 80px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.saved-call-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.saved-call-name {
|
||||
font-size: 14px;
|
||||
color: #e0e0e0;
|
||||
}
|
||||
|
||||
.saved-call-link {
|
||||
font-size: 11px;
|
||||
color: #4fc3f7;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.saved-call-join {
|
||||
padding: 6px 14px;
|
||||
border: 1px solid #444;
|
||||
border-radius: 6px;
|
||||
background: #2a2a2a;
|
||||
color: #e0e0e0;
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.saved-call-join:hover {
|
||||
background: #333;
|
||||
}
|
||||
|
||||
.saved-call-remove {
|
||||
color: #888;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.saved-call-remove:hover {
|
||||
color: #dc3545;
|
||||
}
|
||||
|
||||
body.saved-calls-open #savedCallsPanel {
|
||||
display: block;
|
||||
}
|
||||
|
||||
body.saved-calls-open #welcome,
|
||||
body.saved-calls-open #toolbar,
|
||||
body.saved-calls-open #headlessInfo,
|
||||
body.saved-calls-open #logsPanel,
|
||||
body.saved-calls-open webview {
|
||||
display: none !important;
|
||||
}
|
||||
Reference in new issue
Block a user