V0.2.0 (#37)
* refactor go files, add headless telemost support * js crap -> ts crap * docker-build (#32) Co-authored-by: Mimocro <suzumagefag@gmail.com> * add headless telemost for creator app * UX improvements (#39) * Add search in split tunneling app list * Add captcha detection * Add autoclick settings * headless vk joiner * add headless telemost joiner * refactor go modules * redesign settings dialog * headless option in settings * headless joiner support in MainActivity * display headless vk status in statusBar * update ux for headless in creator app * fix double log render for headless mode in creator * unicode for cyrillic * add socks auth * put socksPort inf prefs, verify that port is free on start * proxy only mode * mask addresses in go network errors * update docker build, add file write logic for headless * increment release version, add make-release script --------- Co-authored-by: kulikov <user@Mac.lan> Co-authored-by: Mimocro <67226986+Mimocro@users.noreply.github.com> Co-authored-by: Mimocro <suzumagefag@gmail.com> Co-authored-by: senya <76913432+senya-sh@users.noreply.github.com>
This commit is contained in:
122 files changed
+9938
-3284
No files matched your search
@@ -1,271 +0,0 @@
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
function generateTabId(tabId) {
|
||||
var hash = 0;
|
||||
for (var i = 0; i < tabId.length; i++) {
|
||||
hash = ((hash << 5) - hash) + tabId.charCodeAt(i);
|
||||
hash = hash & hash;
|
||||
}
|
||||
return Math.abs(hash) % 10000;
|
||||
}
|
||||
|
||||
function findTabById(tabsList, shortId) {
|
||||
var targetId = parseInt(shortId, 10);
|
||||
for (var i = 0; i < tabsList.length; i++) {
|
||||
var t = tabsList[i];
|
||||
if (generateTabId(t.id) === targetId) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function createKeyboard() {
|
||||
return {
|
||||
one_time: false,
|
||||
buttons: [
|
||||
[
|
||||
{ action: { type: 'text', label: '📞 VK DC', payload: JSON.stringify({ cmd: 'vk', mode: 'dc' }) } },
|
||||
{ action: { type: 'text', label: '📹 VK Video', payload: JSON.stringify({ cmd: 'vk', mode: 'video' }) } }
|
||||
],
|
||||
[
|
||||
{ action: { type: 'text', label: '📞 TM DC', payload: JSON.stringify({ cmd: 'tm', mode: 'dc' }) } },
|
||||
{ action: { type: 'text', label: '📹 TM Video', payload: JSON.stringify({ cmd: 'tm', mode: 'video' }) } }
|
||||
],
|
||||
[
|
||||
{ action: { type: 'text', label: '📋 Active Tabs', payload: JSON.stringify({ cmd: 'list' }) } }
|
||||
]
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
function createListKeyboard(tabsList) {
|
||||
var buttons = [];
|
||||
for (var i = 0; i < tabsList.length; i++) {
|
||||
var t = tabsList[i];
|
||||
var shortId = generateTabId(t.id);
|
||||
var paddedId = ('000' + shortId).slice(-4);
|
||||
var prefix = t.isBot ? 'bot' : 'user';
|
||||
var status = t.callStatus === 'active' ? '🟢' : '⚪';
|
||||
buttons.push([
|
||||
{ action: { type: 'text', label: prefix + ' ' + t.platform + ' ' + t.mode + ' ' + paddedId + ' ' + status, payload: JSON.stringify({ cmd: 'close', id: t.id }) } }
|
||||
]);
|
||||
}
|
||||
buttons.push([{ action: { type: 'text', label: '◀️ Back', payload: JSON.stringify({ cmd: 'menu' }) } }]);
|
||||
return {
|
||||
one_time: false,
|
||||
buttons: buttons
|
||||
};
|
||||
}
|
||||
|
||||
class BotManager {
|
||||
constructor(settings, onCreateTab, onGetTabs, onCloseTab) {
|
||||
this.settings = settings;
|
||||
this.onCreateTab = onCreateTab;
|
||||
this.onGetTabs = onGetTabs;
|
||||
this.onCloseTab = onCloseTab;
|
||||
this.baseUrl = 'https://api.vk.com/method';
|
||||
this.ts = null;
|
||||
this.key = null;
|
||||
this.server = null;
|
||||
this.running = false;
|
||||
}
|
||||
async api(method, params = {}) {
|
||||
params.v = '5.131';
|
||||
params.access_token = this.settings.token;
|
||||
const url = new URL(`${this.baseUrl}/${method}`);
|
||||
Object.keys(params).forEach(k => url.searchParams.set(k, params[k]));
|
||||
const res = await fetch(url);
|
||||
const data = await res.json();
|
||||
|
||||
if (data.error) {
|
||||
var errMsg = method + ' code: ' + data.error.error_code + ' msg: ' + (data.error.error_msg || 'VK API error') + ' params: ' + JSON.stringify(data.error.request_params || []);
|
||||
console.error('[BOT] API error:', errMsg);
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
return data.response;
|
||||
}
|
||||
|
||||
async getLongPollServer() {
|
||||
const data = await this.api('groups.getLongPollServer', { group_id: parseInt(this.settings.groupId) });
|
||||
this.server = data.server;
|
||||
this.key = data.key;
|
||||
this.ts = data.ts;
|
||||
return data;
|
||||
}
|
||||
|
||||
async start() {
|
||||
this.running = true;
|
||||
console.log('[BOT] Starting with settings:', this.settings);
|
||||
|
||||
try {
|
||||
await this.getLongPollServer();
|
||||
console.log('[BOT] LongPoll server:', this.server);
|
||||
this.pollLoop();
|
||||
} catch (err) {
|
||||
console.error('[BOT] Failed to start:', err.message);
|
||||
this.running = false;
|
||||
if (this.onError) this.onError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
stop() {
|
||||
this.running = false;
|
||||
console.log('[BOT] Stopped');
|
||||
}
|
||||
|
||||
async pollLoop() {
|
||||
while (this.running) {
|
||||
try {
|
||||
const url = `${this.server}?act=a_check&key=${this.key}&ts=${this.ts}&wait=25`;
|
||||
const res = await fetch(url);
|
||||
const data = await res.json();
|
||||
|
||||
if (data.failed) {
|
||||
console.log('[BOT] LongPoll failed, reconnecting...');
|
||||
await this.getLongPollServer();
|
||||
continue;
|
||||
}
|
||||
this.ts = data.ts;
|
||||
for (const update of data.updates) {
|
||||
await this.handleUpdate(update);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[BOT] Poll error:', err.message);
|
||||
await new Promise(r => setTimeout(r, 1000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async handleUpdate(update) {
|
||||
if (update.type === 'message_new') {
|
||||
const message = update.object.message;
|
||||
var text = (message.text || '').trim();
|
||||
const fromId = message.from_id;
|
||||
const peerId = message.peer_id;
|
||||
|
||||
var payload = null;
|
||||
if (message.payload) {
|
||||
try {
|
||||
payload = JSON.parse(message.payload);
|
||||
console.log('[BOT] Payload from button:', payload);
|
||||
} catch (e) {
|
||||
console.log('[BOT] Failed to parse payload:', message.payload);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('[BOT] Message from', fromId, ':', text, 'payload:', payload);
|
||||
|
||||
if (this.settings.userId && fromId.toString() !== this.settings.userId.toString()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (text === '/start' || text === 'start') {
|
||||
await this.showMenu(peerId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (payload && payload.cmd) {
|
||||
if (payload.cmd === 'list') {
|
||||
await this.showList(peerId);
|
||||
return;
|
||||
} else if (payload.cmd === 'menu') {
|
||||
await this.showMenu(peerId);
|
||||
return;
|
||||
} else if (payload.cmd === 'close') {
|
||||
if (payload.id) {
|
||||
var tabsList = this.onGetTabs ? this.onGetTabs() : [];
|
||||
var foundTab = null;
|
||||
for (var i = 0; i < tabsList.length; i++) {
|
||||
if (tabsList[i].id === payload.id) {
|
||||
foundTab = tabsList[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundTab && this.onCloseTab) {
|
||||
var shortId = generateTabId(foundTab.id);
|
||||
var paddedId = ('000' + shortId).slice(-4);
|
||||
this.onCloseTab(foundTab.id);
|
||||
await this.sendMessage(peerId, foundTab.platform + ' ' + foundTab.mode + ' ' + paddedId + ' closed', createKeyboard());
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else if (payload.cmd === 'vk') {
|
||||
text = '/vk' + (payload.mode === 'video' ? ' video' : '');
|
||||
} else if (payload.cmd === 'tm') {
|
||||
text = '/tm' + (payload.mode === 'video' ? ' video' : '');
|
||||
}
|
||||
}
|
||||
|
||||
if (text.startsWith('/vk')) {
|
||||
const mode = text.includes('video') ? 'pion-video' : 'dc';
|
||||
console.log('[BOT] Creating VK tab with mode:', mode);
|
||||
|
||||
this.onCreateTab({ mode: mode, peerId: peerId, platform: 'vk' });
|
||||
await this.sendMessage(peerId, 'Creating VK call (' + (mode === 'dc' ? 'DC' : 'Video') + ')', createKeyboard());
|
||||
}
|
||||
|
||||
if (text.startsWith('/tm')) {
|
||||
const mode = text.includes('video') ? 'pion-video' : 'dc';
|
||||
console.log('[BOT] Creating Telemost tab with mode:', mode);
|
||||
|
||||
this.onCreateTab({ mode: mode, peerId: peerId, platform: 'telemost' });
|
||||
|
||||
await this.sendMessage(peerId, 'Creating Telemost call (' + (mode === 'dc' ? 'DC' : 'Video') + ')', createKeyboard());
|
||||
}
|
||||
|
||||
if (text === '/list') {
|
||||
await this.showList(peerId);
|
||||
}
|
||||
|
||||
if (text.startsWith('/close ')) {
|
||||
var parts = text.split(' ');
|
||||
var targetShortId = parts[1];
|
||||
console.log('[BOT] Close request for ID:', targetShortId, 'from peer:', peerId);
|
||||
|
||||
var tabsList = this.onGetTabs ? this.onGetTabs() : [];
|
||||
var foundTab = findTabById(tabsList, targetShortId);
|
||||
|
||||
if (!foundTab) {
|
||||
await this.sendMessage(peerId, 'Tab ' + targetShortId + ' not found', createKeyboard());
|
||||
} else if (this.onCloseTab) {
|
||||
this.onCloseTab(foundTab.id);
|
||||
await this.sendMessage(peerId, foundTab.platform + ' ' + foundTab.mode + ' ' + targetShortId + ' closed', createKeyboard());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async sendMessage(peerId, text, keyboard = null) {
|
||||
try {
|
||||
var params = {
|
||||
peer_id: peerId,
|
||||
message: text,
|
||||
random_id: Math.floor(Math.random() * 1e9)
|
||||
};
|
||||
if (keyboard) {
|
||||
params.keyboard = JSON.stringify(keyboard);
|
||||
}
|
||||
await this.api('messages.send', params);
|
||||
console.log('[BOT] Sent message to', peerId);
|
||||
} catch (err) {
|
||||
console.error('[BOT] Send message error:', err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async showMenu(peerId) {
|
||||
await this.sendMessage(peerId, '🤖 Select mode:', createKeyboard());
|
||||
}
|
||||
|
||||
async showList(peerId) {
|
||||
var tabsList = this.onGetTabs ? this.onGetTabs() : [];
|
||||
if (tabsList.length === 0) {
|
||||
await this.sendMessage(peerId, 'No active tabs', createKeyboard());
|
||||
} else {
|
||||
await this.sendMessage(peerId, 'Select tab to close:', createListKeyboard(tabsList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BotManager;
|
||||
@@ -1,24 +0,0 @@
|
||||
(function() {
|
||||
if (window.__callCheckerStarted) return;
|
||||
window.__callCheckerStarted = true;
|
||||
|
||||
var tabId = window.__CALL_CHECKER_TAB_ID || 'unknown';
|
||||
|
||||
console.log('[CALL_STATUS] Checker started for ' + tabId);
|
||||
|
||||
const checkCallStatus = () => {
|
||||
var vkBtn = document.querySelector('button[data-testid="calls_call_footer_button_leave_call"]') ||
|
||||
document.querySelector('[data-testid="calls_call_footer_button_leave_call"]');
|
||||
|
||||
var tmBtn = document.querySelector('[data-testid="end-call-alt-button"]') ||
|
||||
document.querySelector('button[data-testid="end-call-alt-button"]');
|
||||
|
||||
var status = (vkBtn || tmBtn) ? 'active' : 'inactive';
|
||||
|
||||
console.log('[CALL_STATUS] ' + tabId + ':' + status);
|
||||
};
|
||||
setTimeout(function() {
|
||||
checkCallStatus();
|
||||
setInterval(checkCallStatus, 10000);
|
||||
}, 10000);
|
||||
})();
|
||||
+36
-486
@@ -1,111 +1,63 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body { font-family: -apple-system, sans-serif; background: #1a1a1a; color: #e0e0e0; height: 100vh; display: flex; flex-direction: column; }
|
||||
.tab-bar { display: flex; align-items: center; background: #222; border-bottom: 1px solid #333; height: 36px; flex-shrink: 0; }
|
||||
.tab-bar-tabs { display: flex; align-items: center; height: 100%; flex: 1; overflow-x: auto; }
|
||||
.tab-bar-actions { display: flex; align-items: center; height: 100%; border-left: 1px solid #333; }
|
||||
.tab { display: flex; align-items: center; gap: 6px; padding: 0 12px; height: 100%; font-size: 12px; cursor: pointer; border-right: 1px solid #333; white-space: nowrap; color: #888; }
|
||||
.tab.active { background: #1a1a1a; color: #e0e0e0; }
|
||||
.tab .close { font-size: 14px; opacity: 0.5; cursor: pointer; margin-left: 4px; }
|
||||
.tab .close:hover { opacity: 1; }
|
||||
.tab .edit { width: 12px; height: 12px; opacity: 0; cursor: pointer; filter: invert(1) brightness(2); margin-left: 2px; }
|
||||
.tab:hover .edit { opacity: 0.4; }
|
||||
.tab .edit:hover { opacity: 1; }
|
||||
.tab-add { padding: 0 12px; height: 100%; display: flex; align-items: center; font-size: 16px; cursor: pointer; color: #888; }
|
||||
.tab-add:hover { color: #e0e0e0; }
|
||||
.tab-settings { padding: 0 12px; height: 100%; display: flex; align-items: center; font-size: 14px; cursor: pointer; color: #888; }
|
||||
.tab-settings:hover { color: #e0e0e0; }
|
||||
.tab-bot { padding: 0 12px; height: 100%; display: flex; align-items: center; font-size: 12px; cursor: pointer; color: #888; font-weight: 500; }
|
||||
.tab-bot:hover { color: #e0e0e0; }
|
||||
.tab-bot.running { color: #dc3545; }
|
||||
.toolbar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: #252525; border-bottom: 1px solid #333; height: 36px; flex-shrink: 0; }
|
||||
.toolbar button { padding: 3px 12px; border: none; border-radius: 6px; font-size: 12px; cursor: pointer; font-weight: 500; }
|
||||
.btn-vk { background: #0077ff; color: white; }
|
||||
.btn-telemost { background: #fc3f1d; color: white; }
|
||||
.content { flex: 1; position: relative; }
|
||||
.content webview { width: 100%; height: 100%; border: none; position: absolute; top: 0; left: 0; }
|
||||
.content webview.hidden { display: none; }
|
||||
.welcome { display: flex; align-items: center; justify-content: center; height: 100%; flex-direction: column; gap: 16px; }
|
||||
.welcome h1 { font-size: 22px; font-weight: 500; }
|
||||
.welcome p { color: #888; font-size: 14px; }
|
||||
.logs { display: flex; gap: 0; border-top: 1px solid #333; height: 120px; flex-shrink: 0; }
|
||||
.log-panel { flex: 1; display: flex; flex-direction: column; }
|
||||
.log-panel:first-child { border-right: 1px solid #333; }
|
||||
.log-title { font-size: 10px; font-weight: 600; color: #888; padding: 3px 8px; background: #1e1e1e; border-bottom: 1px solid #333; }
|
||||
.log-content { flex: 1; overflow-y: auto; padding: 3px 8px; font-family: monospace; font-size: 10px; background: #111; white-space: pre-wrap; word-break: break-all; }
|
||||
.log-content.relay { color: #4fc3f7; }
|
||||
.log-content.hook { color: #66bb6a; }
|
||||
|
||||
/* Settings Popup */
|
||||
.popup-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); z-index: 1000; display: none; align-items: center; justify-content: center; }
|
||||
.popup-overlay.visible { display: flex; }
|
||||
.popup { background: #2a2a2a; border-radius: 12px; padding: 24px; width: 400px; box-shadow: 0 8px 32px rgba(0,0,0,0.4); }
|
||||
.popup h2 { margin: 0 0 20px; font-size: 18px; font-weight: 600; color: #e0e0e0; }
|
||||
.popup label { display: block; margin-bottom: 6px; font-size: 12px; color: #888; font-weight: 500; }
|
||||
.popup input { width: 100%; padding: 10px 12px; border: 1px solid #444; border-radius: 8px; font-size: 14px; background: #1a1a1a; color: #e0e0e0; outline: none; margin-bottom: 16px; box-sizing: border-box; }
|
||||
.popup input:focus { border-color: #0077ff; }
|
||||
.popup-buttons { display: flex; gap: 8px; justify-content: flex-end; }
|
||||
.popup button { padding: 8px 16px; border: none; border-radius: 8px; font-size: 13px; cursor: pointer; font-weight: 500; }
|
||||
.btn-save { background: #0077ff; color: white; }
|
||||
.btn-cancel { background: #444; color: #e0e0e0; }
|
||||
.btn-bot { background: #6f42c1; color: white; }
|
||||
.btn-bot.running { background: #dc3545; }
|
||||
</style>
|
||||
<link rel="stylesheet" href="styles/main.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="tab-bar">
|
||||
<div class="tab-bar-tabs" id="tabBar">
|
||||
<div class="tab-add" onclick="addTab()" title="New tab">+</div>
|
||||
<div class="tab-add" data-action="add-tab" title="New tab">+</div>
|
||||
</div>
|
||||
<div class="tab-bar-actions">
|
||||
<div class="tab-settings" onclick="copyCookies()" title="Export VK cookies to cookies.json for headless mode" style="cursor:pointer">Export Cookies</div>
|
||||
<div class="tab-settings" onclick="openSettings()" title="Settings">Settings</div>
|
||||
<div class="tab-bot" id="tabBot" onclick="toggleBot()">Bot: Off</div>
|
||||
<div class="tab-action-btn" id="btnVkCookies" title="Export VK cookies to vk-cookies.json for headless mode">VK Cookies</div>
|
||||
<div class="tab-action-btn" id="btnYandexCookies" title="Export Yandex cookies to cookies-yandex.json for headless mode">Yandex Cookies</div>
|
||||
<div class="tab-action-btn settings" id="btnSettings" title="Settings">Settings</div>
|
||||
<div class="tab-action-btn bot" id="tabBot">Bot: Off</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="toolbar" id="toolbar" style="display:none">
|
||||
<button class="btn-vk" onclick="loadURL('https://vk.com/im')">VK</button>
|
||||
<button class="btn-telemost" onclick="loadURL('https://telemost.yandex.ru/')">Telemost</button>
|
||||
<button class="btn-vk" onclick="startHeadlessVK()" style="opacity:0.8">Headless VK</button>
|
||||
<span style="margin-left:auto;font-size:11px;color:#888">Tunnel:</span>
|
||||
<select id="modeSelect" style="padding:2px 6px;border:1px solid #555;border-radius:6px;font-size:11px;cursor:pointer;font-weight:500;background:#333;color:#e0e0e0;outline:none" onchange="onModeChange(this.value)">
|
||||
<button class="btn-vk" id="btnVk">VK</button>
|
||||
<button class="btn-telemost" id="btnTelemost">Telemost</button>
|
||||
<button class="btn-headless" id="btnHeadlessVK">Headless VK</button>
|
||||
<button class="btn-headless-tm" id="btnHeadlessTM">Headless TM</button>
|
||||
<span class="toolbar-spacer"></span>
|
||||
<span class="toolbar-label">Tunnel:</span>
|
||||
<select id="modeSelect" class="toolbar-select">
|
||||
<option value="dc">DC</option>
|
||||
<option value="pion-video">Video</option>
|
||||
</select>
|
||||
<span onclick="saveLogs()" style="cursor:pointer;margin-left:8px" title="Save logs"><img src="resources/icons8-download-64.png" style="height:16px;vertical-align:middle;filter:invert(1) brightness(2)"></span>
|
||||
<span class="toolbar-icon" id="btnSaveLogs" title="Save logs"><img src="resources/icons8-download-64.png"></span>
|
||||
</div>
|
||||
<div class="content" id="content">
|
||||
<div class="welcome" id="welcome">
|
||||
<h1>Whitelist Bypass - Creator</h1>
|
||||
<p>Click + to add a tab</p>
|
||||
</div>
|
||||
<div class="headless-info" id="headlessInfo" style="display:none;padding:24px;color:#e0e0e0;font-family:monospace;font-size:14px">
|
||||
<div style="font-size:18px;font-weight:bold;margin-bottom:16px">Headless VK</div>
|
||||
<div id="headlessStatus" style="color:#888">Starting...</div>
|
||||
<div id="headlessCallInfo" style="margin-top:16px;display:none">
|
||||
<div style="margin-bottom:8px"><span style="color:#888">Join link:</span> <a id="headlessJoinLink" href="#" style="color:#4fc3f7;cursor:pointer" onclick="copyToClipboard(this.textContent)"></a></div>
|
||||
<div style="margin-bottom:8px"><span style="color:#888">Short:</span> <a id="headlessShortLink" href="#" style="color:#4fc3f7;cursor:pointer" onclick="copyToClipboard(this.textContent)"></a></div>
|
||||
<div style="margin-bottom:8px"><span style="color:#888">TURN:</span> <span id="headlessTurn"></span></div>
|
||||
<div style="margin-bottom:8px"><span style="color:#888">Protocol:</span> <span id="headlessProtocol"></span></div>
|
||||
<div class="headless-info" id="headlessInfo">
|
||||
<div class="headless-title" id="headlessTitle">Headless</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">Short:</span> <a id="headlessShortLink" href="#" class="headless-link"></a><img class="headless-copy" src="resources/icons8-copy-50.png" data-copy="headlessShortLink" title="Copy"></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">Protocol:</span> <span id="headlessTMProtocol"></span></div>
|
||||
</div>
|
||||
<div id="headlessTunnel" style="margin-top:16px;display:none;color:#4caf50;font-weight:bold;font-size:16px">TUNNEL CONNECTED</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="logs" id="logsPanel" style="display:none">
|
||||
<div class="log-panel">
|
||||
<div class="log-title">Relay <span onclick="clearLog('relay')" style="cursor:pointer;float:right" title="Clear"><span style="font-size:13px;line-height:13px">✕</span></span></div>
|
||||
<div class="log-title">Relay <span class="log-clear-btn" id="btnClearRelay" title="Clear">✕</span></div>
|
||||
<div class="log-content relay" id="relayLog"></div>
|
||||
</div>
|
||||
<div class="log-panel">
|
||||
<div class="log-title">Hook <span onclick="clearLog('hook')" style="cursor:pointer;float:right" title="Clear"><span style="font-size:13px;line-height:13px">✕</span></span></div>
|
||||
<div class="log-title">Hook <span class="log-clear-btn" id="btnClearHook" title="Clear">✕</span></div>
|
||||
<div class="log-content hook" id="hookLog"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Settings Popup -->
|
||||
<div class="popup-overlay" id="settingsPopup">
|
||||
<div class="popup">
|
||||
<h2>VK bot settings</h2>
|
||||
@@ -116,422 +68,20 @@ body { font-family: -apple-system, sans-serif; background: #1a1a1a; color: #e0e0
|
||||
<label for="vkUserId">User ID</label>
|
||||
<input type="number" id="vkUserId" placeholder="123456789">
|
||||
<div class="popup-buttons">
|
||||
<button class="btn-cancel" onclick="closeSettings()">Cancel</button>
|
||||
<button class="btn-save" onclick="saveSettings()">Save</button>
|
||||
<button class="btn-cancel" id="btnSettingsCancel">Cancel</button>
|
||||
<button class="btn-save" id="btnSettingsSave">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="popup-overlay" id="errorPopup" onclick="closeError()">
|
||||
<div class="popup" style="padding:16px" onclick="event.stopPropagation()">
|
||||
<h2 style="color:#dc3545;margin-bottom:12px;font-size:15px">Bot error</h2>
|
||||
<pre id="errorText" style="background:#111;padding:10px;border-radius:6px;font-size:11px;color:#e0e0e0;white-space:pre-wrap;word-break:break-all;max-height:200px;overflow-y:auto;user-select:text;cursor:text;margin:0"></pre>
|
||||
<div class="popup-overlay" id="errorPopup">
|
||||
<div class="popup" style="padding:16px">
|
||||
<h2 class="error-title">Bot error</h2>
|
||||
<pre class="error-text" id="errorText"></pre>
|
||||
<div class="popup-buttons" style="margin-top:12px">
|
||||
<button class="btn-cancel" onclick="closeError()">Close</button>
|
||||
<button class="btn-cancel" id="btnErrorClose">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function showError(msg) {
|
||||
document.getElementById('errorText').textContent = msg;
|
||||
document.getElementById('errorPopup').classList.add('visible');
|
||||
}
|
||||
function closeError() {
|
||||
document.getElementById('errorPopup').classList.remove('visible');
|
||||
}
|
||||
|
||||
window.bridge.onBotError(function(msg) {
|
||||
showError(msg);
|
||||
botRunning = false;
|
||||
localStorage.setItem('botEnabled', 'false');
|
||||
var btn = document.getElementById('tabBot');
|
||||
btn.textContent = 'Bot: Off';
|
||||
btn.classList.remove('running');
|
||||
});
|
||||
|
||||
function copyCookies() {
|
||||
window.bridge.getCookies('.vk.com').then(function(cookies) {
|
||||
if (!cookies.length) {
|
||||
showError('No VK cookies found.\nPlease log into VK first.');
|
||||
return;
|
||||
}
|
||||
var simple = cookies.map(function(c) { return { name: c.name, value: c.value }; });
|
||||
var blob = new Blob([JSON.stringify(simple, null, 2)], { type: 'application/json' });
|
||||
var link = document.createElement('a');
|
||||
link.href = URL.createObjectURL(blob);
|
||||
link.download = 'cookies.json';
|
||||
link.click();
|
||||
});
|
||||
}
|
||||
|
||||
var tabsState = {}; // tabId -> { wv, mode, relayLogs, hookLogs }
|
||||
var activeTabId = null;
|
||||
var nextTabId = 1;
|
||||
var botRunning = false;
|
||||
|
||||
var savedSettings = localStorage.getItem('botSettings');
|
||||
var botSettings = savedSettings ? JSON.parse(savedSettings) : { token: '', groupId: '', userId: '' };
|
||||
|
||||
if (localStorage.getItem('botEnabled') === 'true' && botSettings.token && botSettings.groupId) {
|
||||
botRunning = true;
|
||||
var btn = document.getElementById('tabBot');
|
||||
btn.textContent = 'Bot: On';
|
||||
btn.classList.add('running');
|
||||
window.bridge.startBot(botSettings);
|
||||
}
|
||||
|
||||
function openSettings() {
|
||||
document.getElementById('settingsPopup').classList.add('visible');
|
||||
document.getElementById('vkToken').value = botSettings.token;
|
||||
document.getElementById('vkGroupId').value = botSettings.groupId;
|
||||
document.getElementById('vkUserId').value = botSettings.userId;
|
||||
}
|
||||
|
||||
function closeSettings() {
|
||||
document.getElementById('settingsPopup').classList.remove('visible');
|
||||
}
|
||||
|
||||
function saveSettings() {
|
||||
botSettings.token = document.getElementById('vkToken').value.trim();
|
||||
botSettings.groupId = document.getElementById('vkGroupId').value.trim();
|
||||
botSettings.userId = document.getElementById('vkUserId').value.trim();
|
||||
localStorage.setItem('botSettings', JSON.stringify(botSettings));
|
||||
closeSettings();
|
||||
console.log('[BOT] Settings saved:', botSettings);
|
||||
}
|
||||
|
||||
function toggleBot() {
|
||||
if (!botSettings.token || !botSettings.groupId) {
|
||||
openSettings();
|
||||
return;
|
||||
}
|
||||
botRunning = !botRunning;
|
||||
localStorage.setItem('botEnabled', botRunning ? 'true' : 'false');
|
||||
var btn = document.getElementById('tabBot');
|
||||
if (botRunning) {
|
||||
btn.textContent = 'Bot: On';
|
||||
btn.classList.add('running');
|
||||
window.bridge.startBot(botSettings);
|
||||
} else {
|
||||
btn.textContent = 'Bot: Off';
|
||||
btn.classList.remove('running');
|
||||
window.bridge.stopBot();
|
||||
}
|
||||
}
|
||||
|
||||
function addTab() {
|
||||
var tabId = 'tab-' + (nextTabId++);
|
||||
tabsState[tabId] = { wv: null, url: '', mode: 'dc', relayLogs: '', hookLogs: '', name: '', isBot: false };
|
||||
window.bridge.startRelay(tabId);
|
||||
renderTabs();
|
||||
selectTab(tabId);
|
||||
}
|
||||
|
||||
function startHeadlessVK() {
|
||||
var tabId = 'tab-' + (nextTabId++);
|
||||
tabsState[tabId] = { wv: null, url: '', mode: 'headless-vk', relayLogs: '', hookLogs: '', name: 'Headless VK', isBot: false, headless: true };
|
||||
window.bridge.startHeadless(tabId);
|
||||
renderTabs();
|
||||
selectTab(tabId);
|
||||
}
|
||||
|
||||
function closeTab(tabId, e) {
|
||||
if (e) e.stopPropagation();
|
||||
var t = tabsState[tabId];
|
||||
if (t && t.wv) t.wv.remove();
|
||||
window.bridge.closeTab(tabId);
|
||||
delete tabsState[tabId];
|
||||
if (activeTabId === tabId) {
|
||||
var ids = Object.keys(tabsState);
|
||||
activeTabId = ids.length > 0 ? ids[ids.length - 1] : null;
|
||||
}
|
||||
renderTabs();
|
||||
renderContent();
|
||||
}
|
||||
|
||||
function selectTab(tabId) {
|
||||
if (activeTabId && tabsState[activeTabId]) {
|
||||
tabsState[activeTabId].relayLogs = document.getElementById('relayLog').textContent;
|
||||
tabsState[activeTabId].hookLogs = document.getElementById('hookLog').textContent;
|
||||
}
|
||||
activeTabId = tabId;
|
||||
renderTabs();
|
||||
renderContent();
|
||||
}
|
||||
|
||||
function getTabLabel(t) {
|
||||
if (t.name) return t.name;
|
||||
if (t.url) {
|
||||
if (t.url.includes('vk.com')) return 'VK';
|
||||
if (t.url.includes('telemost')) return 'Telemost';
|
||||
}
|
||||
return 'New';
|
||||
}
|
||||
|
||||
function renderTabs() {
|
||||
var bar = document.getElementById('tabBar');
|
||||
var html = '';
|
||||
Object.keys(tabsState).forEach(function(id) {
|
||||
var t = tabsState[id];
|
||||
var label = getTabLabel(t);
|
||||
var cls = id === activeTabId ? 'tab active' : 'tab';
|
||||
html += '<div class="' + cls + '" onclick="selectTab(\'' + id + '\')"><span class="tab-label">' + label + '</span><img class="edit" src="resources/icons8-pencil-50.png" onclick="renameTab(\'' + id + '\', event)"> <span class="close" onclick="closeTab(\'' + id + '\', event)">✕</span></div>';
|
||||
});
|
||||
html += '<div class="tab-add" onclick="addTab()" title="New tab">+</div>';
|
||||
bar.innerHTML = html;
|
||||
}
|
||||
|
||||
function renameTab(tabId, e) {
|
||||
e.stopPropagation();
|
||||
var tab = e.target.closest('.tab');
|
||||
var span = tab.querySelector('.tab-label');
|
||||
var inp = document.createElement('input');
|
||||
inp.type = 'text';
|
||||
inp.value = tabsState[tabId].name || '';
|
||||
inp.placeholder = getTabLabel(tabsState[tabId]);
|
||||
inp.style.cssText = 'width:80px;padding:0 4px;border:1px solid #555;border-radius:4px;font-size:12px;background:#111;color:#e0e0e0;outline:none';
|
||||
span.replaceWith(inp);
|
||||
inp.focus();
|
||||
inp.select();
|
||||
var done = function() {
|
||||
tabsState[tabId].name = inp.value.trim();
|
||||
renderTabs();
|
||||
};
|
||||
inp.addEventListener('blur', done);
|
||||
inp.addEventListener('keydown', function(ev) {
|
||||
if (ev.key === 'Enter') inp.blur();
|
||||
if (ev.key === 'Escape') { inp.value = ''; inp.blur(); }
|
||||
});
|
||||
}
|
||||
|
||||
function renderContent() {
|
||||
var content = document.getElementById('content');
|
||||
var welcome = document.getElementById('welcome');
|
||||
var toolbar = document.getElementById('toolbar');
|
||||
var logsPanel = document.getElementById('logsPanel');
|
||||
var wvs = content.querySelectorAll('webview');
|
||||
for (var i = 0; i < wvs.length; i++) wvs[i].classList.add('hidden');
|
||||
|
||||
if (!activeTabId || !tabsState[activeTabId]) {
|
||||
welcome.style.display = 'flex';
|
||||
toolbar.style.display = 'none';
|
||||
logsPanel.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
welcome.style.display = 'none';
|
||||
logsPanel.style.display = 'flex';
|
||||
|
||||
var t = tabsState[activeTabId];
|
||||
var headlessInfo = document.getElementById('headlessInfo');
|
||||
if (t.headless) {
|
||||
toolbar.style.display = 'none';
|
||||
headlessInfo.style.display = 'block';
|
||||
document.getElementById('headlessStatus').textContent = t.headlessStatus || 'Starting...';
|
||||
var ci = t.callInfo;
|
||||
if (ci) {
|
||||
document.getElementById('headlessCallInfo').style.display = 'block';
|
||||
document.getElementById('headlessJoinLink').textContent = ci.joinLink || '';
|
||||
document.getElementById('headlessShortLink').textContent = ci.shortLink || '';
|
||||
document.getElementById('headlessTurn').textContent = ci.turn || '';
|
||||
document.getElementById('headlessProtocol').textContent = ci.protocol || '';
|
||||
} else {
|
||||
document.getElementById('headlessCallInfo').style.display = 'none';
|
||||
}
|
||||
document.getElementById('headlessTunnel').style.display = t.tunnelConnected ? 'block' : 'none';
|
||||
} else {
|
||||
toolbar.style.display = 'flex';
|
||||
headlessInfo.style.display = 'none';
|
||||
document.getElementById('modeSelect').value = t.mode;
|
||||
if (t.wv) t.wv.classList.remove('hidden');
|
||||
}
|
||||
document.getElementById('relayLog').textContent = t.relayLogs || '';
|
||||
document.getElementById('hookLog').textContent = t.hookLogs || '';
|
||||
scrollLogs();
|
||||
}
|
||||
|
||||
function scrollLogs() {
|
||||
var r = document.getElementById('relayLog');
|
||||
var h = document.getElementById('hookLog');
|
||||
r.scrollTop = r.scrollHeight;
|
||||
h.scrollTop = h.scrollHeight;
|
||||
}
|
||||
|
||||
function loadURL(url) {
|
||||
if (!activeTabId) return;
|
||||
var t = tabsState[activeTabId];
|
||||
if (t.wv) t.wv.remove();
|
||||
var wv = document.createElement('webview');
|
||||
wv.setAttribute('src', url);
|
||||
wv.setAttribute('partition', 'persist:creator');
|
||||
wv.setAttribute('nodeintegration', '');
|
||||
wv.setAttribute('nodeintegrationinsubframes', '');
|
||||
wv.style.width = '100%';
|
||||
wv.style.height = '100%';
|
||||
wv.style.position = 'absolute';
|
||||
wv.style.top = '0';
|
||||
wv.style.left = '0';
|
||||
wv.dataset.tabId = activeTabId;
|
||||
document.getElementById('content').appendChild(wv);
|
||||
wv.addEventListener('dom-ready', function() {
|
||||
wv.setAudioMuted(true);
|
||||
var tabId = wv.dataset.tabId;
|
||||
window.bridge.getHookCode(tabId, wv.getURL()).then(function(code) {
|
||||
wv.executeJavaScript(code).catch(function() {});
|
||||
});
|
||||
|
||||
window.bridge.getCallCreatorCode('call-checker.js').then(function(checkerCode) {
|
||||
console.log('[UI] Injecting call checker for tab:', tabId);
|
||||
var injectCode = 'window.__CALL_CHECKER_TAB_ID = "' + tabId + '"; ' + checkerCode;
|
||||
wv.executeJavaScript(injectCode).catch(function(err) {
|
||||
console.log('[UI] Call checker inject error:', err);
|
||||
});
|
||||
}).catch(function(err) {
|
||||
console.log('[UI] Failed to get call-checker.js:', err);
|
||||
});
|
||||
|
||||
if (tabsState[tabId] && tabsState[tabId].isBot) {
|
||||
setTimeout(function() {
|
||||
var scriptFile = tabsState[tabId].platform === 'telemost' ? 'tm-call-creator.js' : 'vk-call-creator.js';
|
||||
window.bridge.getCallCreatorCode(scriptFile).then(function(callCreatorCode) {
|
||||
wv.executeJavaScript(callCreatorCode).catch(function() {});
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
wv.addEventListener('did-navigate', function() {
|
||||
t.url = wv.getURL() || t.url;
|
||||
renderTabs();
|
||||
var tabId = wv.dataset.tabId;
|
||||
wv.executeJavaScript('window.__hookInstalled = false').catch(function() {});
|
||||
window.bridge.getHookCode(tabId, wv.getURL()).then(function(code) {
|
||||
wv.executeJavaScript(code).catch(function() {});
|
||||
});
|
||||
window.bridge.getCallCreatorCode('call-checker.js').then(function(checkerCode) {
|
||||
var injectCode = 'window.__CALL_CHECKER_TAB_ID = "' + tabId + '"; ' + checkerCode;
|
||||
wv.executeJavaScript(injectCode).catch(function() {});
|
||||
});
|
||||
});
|
||||
t.wv = wv;
|
||||
t.url = url;
|
||||
renderTabs();
|
||||
}
|
||||
|
||||
function onModeChange(mode) {
|
||||
if (!activeTabId) return;
|
||||
var t = tabsState[activeTabId];
|
||||
t.mode = mode;
|
||||
window.bridge.setTunnelMode(activeTabId, mode).then(function() {
|
||||
if (t.wv) {
|
||||
t.wv.executeJavaScript('window.__hookInstalled = false').catch(function() {});
|
||||
t.wv.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function clearLog(type) {
|
||||
document.getElementById(type === 'relay' ? 'relayLog' : 'hookLog').textContent = '';
|
||||
}
|
||||
|
||||
function saveLogs() {
|
||||
var relay = document.getElementById('relayLog').textContent;
|
||||
var hook = document.getElementById('hookLog').textContent;
|
||||
var text = '=== RELAY ===\n' + relay + '\n\n=== HOOK ===\n' + hook;
|
||||
var blob = new Blob([text], { type: 'text/plain' });
|
||||
var a = document.createElement('a');
|
||||
a.href = URL.createObjectURL(blob);
|
||||
a.download = 'tunnel-logs-' + new Date().toISOString().replace(/[:.]/g, '-') + '.txt';
|
||||
a.click();
|
||||
}
|
||||
|
||||
setInterval(function() {
|
||||
if (!activeTabId || !tabsState[activeTabId] || !tabsState[activeTabId].wv) return;
|
||||
tabsState[activeTabId].wv.executeJavaScript('(window.__hookLogs && window.__hookLogs.length) ? window.__hookLogs.splice(0) : []')
|
||||
.then(function(logs) {
|
||||
if (!logs.length) return;
|
||||
var el = document.getElementById('hookLog');
|
||||
logs.forEach(function(msg) {
|
||||
if (el.textContent.length > 0) el.textContent += '\n';
|
||||
el.textContent += msg.replace('[HOOK] ', '');
|
||||
});
|
||||
el.scrollTop = el.scrollHeight;
|
||||
}).catch(function() {});
|
||||
}, 500);
|
||||
|
||||
window.bridge.onRelayLog(function(tabId, msg) {
|
||||
if (tabsState[tabId]) {
|
||||
tabsState[tabId].relayLogs += (tabsState[tabId].relayLogs ? '\n' : '') + msg;
|
||||
if (tabsState[tabId].headless) parseHeadlessLog(tabId, msg);
|
||||
}
|
||||
if (tabId === activeTabId) {
|
||||
var el = document.getElementById('relayLog');
|
||||
if (el.textContent.length > 0) el.textContent += '\n';
|
||||
el.textContent += msg;
|
||||
el.scrollTop = el.scrollHeight;
|
||||
}
|
||||
});
|
||||
|
||||
function parseHeadlessLog(tabId, msg) {
|
||||
var t = tabsState[tabId];
|
||||
if (!t) return;
|
||||
var trimmed = msg.trim();
|
||||
if (trimmed === 'CALL CREATED') {
|
||||
t.callInfo = {};
|
||||
t.headlessStatus = 'Call created';
|
||||
}
|
||||
if (trimmed.indexOf('join_link:') !== -1) {
|
||||
if (!t.callInfo) t.callInfo = {};
|
||||
t.callInfo.joinLink = trimmed.split('join_link:')[1].trim();
|
||||
}
|
||||
if (trimmed.indexOf('short:') !== -1) {
|
||||
if (!t.callInfo) t.callInfo = {};
|
||||
t.callInfo.shortLink = trimmed.split('short:')[1].trim();
|
||||
}
|
||||
if (trimmed.indexOf('TURN:') !== -1) {
|
||||
if (!t.callInfo) t.callInfo = {};
|
||||
t.callInfo.turn = trimmed.split('TURN:')[1].trim();
|
||||
}
|
||||
if (trimmed.indexOf('protocol:') !== -1) {
|
||||
if (!t.callInfo) t.callInfo = {};
|
||||
t.callInfo.protocol = trimmed.split('protocol:')[1].trim();
|
||||
}
|
||||
if (trimmed === 'TUNNEL CONNECTED') {
|
||||
t.tunnelConnected = true;
|
||||
t.headlessStatus = 'Tunnel connected';
|
||||
}
|
||||
if (tabId === activeTabId) renderContent();
|
||||
}
|
||||
|
||||
function copyToClipboard(text) {
|
||||
navigator.clipboard.writeText(text);
|
||||
}
|
||||
|
||||
window.bridge.onCreateBotTab(function(data) {
|
||||
console.log('[BOT] Creating tab:', data);
|
||||
var tabId = data.tabId;
|
||||
var mode = data.mode;
|
||||
var peerId = data.peerId;
|
||||
var platform = data.platform || 'vk';
|
||||
|
||||
if (!tabsState[tabId]) {
|
||||
var botName = platform === 'telemost' ? 'Bot-Telemost' : 'Bot-VK';
|
||||
tabsState[tabId] = { wv: null, url: '', mode: mode, relayLogs: '', hookLogs: '', name: botName, isBot: true, peerId: peerId, platform: platform };
|
||||
}
|
||||
|
||||
selectTab(tabId);
|
||||
|
||||
document.getElementById('modeSelect').value = mode;
|
||||
window.bridge.setTunnelMode(tabId, mode);
|
||||
|
||||
if (platform === 'telemost') {
|
||||
loadURL('https://telemost.yandex.ru/');
|
||||
} else {
|
||||
loadURL('https://vk.com/im');
|
||||
}
|
||||
});
|
||||
|
||||
window.bridge.onCloseBotTab(function(data) {
|
||||
console.log('[BOT] Closing tab:', data.tabId);
|
||||
closeTab(data.tabId);
|
||||
});
|
||||
</script>
|
||||
<script>require('./dist/renderer/index.js')</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,387 +0,0 @@
|
||||
const { app, BrowserWindow, session, ipcMain } = require('electron');
|
||||
const { spawn } = require('child_process');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const TelemostAutoclick = require('./telemost-autoclick');
|
||||
const VkAutoclick = require('./vk-autoclick');
|
||||
const BotManager = require('./bot-manager');
|
||||
|
||||
var hooksDir = app.isPackaged
|
||||
? path.join(process.resourcesPath, 'hooks')
|
||||
: path.join(__dirname, '..', 'hooks');
|
||||
var logCapture = "if(!window.__logCaptureInstalled){window.__logCaptureInstalled=true;window.__hookLogs=[];var _ol=console.log.bind(console);console.log=function(){_ol.apply(null,arguments);var m=Array.prototype.slice.call(arguments).join(' ');if(m.indexOf('[HOOK]')!==-1)window.__hookLogs.push(m)}}";
|
||||
var relayPath = app.isPackaged
|
||||
? path.join(process.resourcesPath, process.platform === 'win32' ? 'relay.exe' : 'relay')
|
||||
: path.join(__dirname, '..', 'relay', process.platform === 'win32' ? 'relay.exe' : 'relay');
|
||||
var headlessPath = app.isPackaged
|
||||
? path.join(process.resourcesPath, process.platform === 'win32' ? 'headless-creator.exe' : 'headless-creator')
|
||||
: path.join(__dirname, '..', 'headless', process.platform === 'win32' ? 'headless-creator.exe' : 'headless-creator');
|
||||
var headlessPath = app.isPackaged
|
||||
? path.join(process.resourcesPath, process.platform === 'win32' ? 'headless-creator.exe' : 'headless-creator')
|
||||
: path.join(__dirname, '..', 'headless', process.platform === 'win32' ? 'headless-creator.exe' : 'headless-creator');
|
||||
|
||||
var tabs = new Map(); // tabId -> { relay, tunnelMode, platform, dcPort, pionPort, isBot }
|
||||
var callStatusCache = new Map();
|
||||
var nextPortBase = 10000;
|
||||
var mainWindow = null;
|
||||
var botManager = null;
|
||||
var botTabs = new Set();
|
||||
|
||||
function isPortFree(port) {
|
||||
return new Promise(function(resolve) {
|
||||
var server = require('net').createServer();
|
||||
server.once('error', function() { resolve(false); });
|
||||
server.once('listening', function() { server.close(function() { resolve(true); }); });
|
||||
server.listen(port, '127.0.0.1');
|
||||
});
|
||||
}
|
||||
|
||||
async function allocPorts() {
|
||||
while (true) {
|
||||
var dc = nextPortBase;
|
||||
var pion = nextPortBase + 1;
|
||||
nextPortBase += 2;
|
||||
var dcFree = await isPortFree(dc);
|
||||
var pionFree = await isPortFree(pion);
|
||||
if (dcFree && pionFree) return { dc: dc, pion: pion };
|
||||
}
|
||||
}
|
||||
|
||||
async function getTab(tabId) {
|
||||
if (!tabs.has(tabId)) {
|
||||
var ports = await allocPorts();
|
||||
tabs.set(tabId, { relay: null, tunnelMode: 'dc', platform: 'vk', dcPort: ports.dc, pionPort: ports.pion });
|
||||
}
|
||||
return tabs.get(tabId);
|
||||
}
|
||||
|
||||
function loadHook(url, tab) {
|
||||
var isTelemost = url.includes('telemost.yandex');
|
||||
var newPlatform = isTelemost ? 'telemost' : 'vk';
|
||||
if (newPlatform !== tab.platform && tab.tunnelMode.startsWith('pion')) {
|
||||
tab.platform = newPlatform;
|
||||
killRelay(tab);
|
||||
setTimeout(function() { startRelay(tab); }, 500);
|
||||
} else {
|
||||
tab.platform = newPlatform;
|
||||
}
|
||||
if (tab.tunnelMode === 'pion-video') {
|
||||
var hookFile = isTelemost ? 'video-telemost.js' : 'video-vk.js';
|
||||
var hook = fs.readFileSync(path.join(hooksDir, hookFile), 'utf8');
|
||||
return logCapture + 'window.PION_PORT=' + tab.pionPort + ';window.IS_CREATOR=true;' + hook;
|
||||
}
|
||||
var hookFile = isTelemost ? 'dc-creator-telemost.js' : 'dc-creator-vk.js';
|
||||
var hook = fs.readFileSync(path.join(hooksDir, hookFile), 'utf8');
|
||||
return logCapture + 'window.WS_PORT=' + tab.dcPort + ';' + hook;
|
||||
}
|
||||
|
||||
async function getVKCookieString() {
|
||||
var ses = session.fromPartition('persist:creator');
|
||||
var all = await ses.cookies.get({});
|
||||
var vkCookies = all.filter(function(c) {
|
||||
return c.domain && (c.domain.indexOf('vk.com') !== -1 || c.domain.indexOf('vk.ru') !== -1);
|
||||
});
|
||||
return vkCookies.map(function(c) { return c.name + '=' + c.value; }).join('; ');
|
||||
}
|
||||
|
||||
function startRelay(tab) {
|
||||
killRelay(tab);
|
||||
var port = tab.tunnelMode.startsWith('pion') ? tab.pionPort : tab.dcPort;
|
||||
var relayMode = 'dc-creator';
|
||||
if (tab.tunnelMode === 'pion-video') {
|
||||
relayMode = tab.platform === 'telemost' ? 'telemost-video-creator' : 'vk-video-creator';
|
||||
}
|
||||
var proc = spawn(relayPath, ['--mode', relayMode, '--ws-port', String(port)], {
|
||||
stdio: ['ignore', 'pipe', 'pipe']
|
||||
});
|
||||
tab.relay = proc;
|
||||
var tabId = null;
|
||||
tabs.forEach(function(t, id) { if (t === tab) tabId = id; });
|
||||
var onData = function(data) {
|
||||
data.toString().trim().split('\n').forEach(function(msg) {
|
||||
if (!msg) return;
|
||||
console.log('[relay:' + tabId + ']', msg);
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('relay-log', { tabId: tabId, msg: msg });
|
||||
}
|
||||
});
|
||||
};
|
||||
proc.stdout.on('data', onData);
|
||||
proc.stderr.on('data', onData);
|
||||
proc.on('close', function(code) {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('relay-log', { tabId: tabId, msg: 'Relay exited with code ' + code });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function killRelay(tab) {
|
||||
if (tab.relay) {
|
||||
tab.relay.kill();
|
||||
tab.relay = null;
|
||||
}
|
||||
}
|
||||
|
||||
function killAllRelays() {
|
||||
tabs.forEach(function(tab) { killRelay(tab); });
|
||||
}
|
||||
|
||||
function stripCSP(ses) {
|
||||
ses.webRequest.onHeadersReceived(function(details, callback) {
|
||||
var headers = Object.assign({}, details.responseHeaders);
|
||||
delete headers['content-security-policy'];
|
||||
delete headers['Content-Security-Policy'];
|
||||
delete headers['content-security-policy-report-only'];
|
||||
delete headers['Content-Security-Policy-Report-Only'];
|
||||
callback({ responseHeaders: headers });
|
||||
});
|
||||
}
|
||||
|
||||
function createWindow() {
|
||||
var ses = session.fromPartition('persist:creator');
|
||||
stripCSP(ses);
|
||||
ses.setPermissionRequestHandler(function(wc, perm, cb) { cb(true); });
|
||||
ses.setPermissionCheckHandler(function() { return true; });
|
||||
ses.setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36');
|
||||
app.on('session-created', stripCSP);
|
||||
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1200,
|
||||
height: 800,
|
||||
icon: path.join(__dirname, 'resources', 'icon.png'),
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
webviewTag: true
|
||||
}
|
||||
});
|
||||
|
||||
mainWindow.loadFile('index.html');
|
||||
mainWindow.on('closed', function() { mainWindow = null; });
|
||||
|
||||
var autoclickers = new Map(); // tabId -> { telemost, vk }
|
||||
|
||||
mainWindow.webContents.on('did-attach-webview', function(e, wvContents) {
|
||||
wvContents.on('before-input-event', function(e, input) {
|
||||
if (input.key === 'F12') wvContents.openDevTools();
|
||||
});
|
||||
wvContents.on('did-navigate', function(e, url) {
|
||||
var tabId = wvContents.id;
|
||||
if (!autoclickers.has(tabId)) {
|
||||
autoclickers.set(tabId, { telemost: new TelemostAutoclick(), vk: new VkAutoclick() });
|
||||
}
|
||||
var ac = autoclickers.get(tabId);
|
||||
if (url.includes('telemost.yandex')) {
|
||||
ac.vk.stop();
|
||||
ac.telemost.attach(wvContents);
|
||||
} else if (url.includes('vk.com')) {
|
||||
ac.telemost.stop();
|
||||
ac.vk.attach(wvContents);
|
||||
} else {
|
||||
ac.telemost.stop();
|
||||
ac.vk.stop();
|
||||
}
|
||||
});
|
||||
wvContents.on('console-message', function(e, level, msg) {
|
||||
if (msg.indexOf('state: disconnected') !== -1 || msg.indexOf('state: failed') !== -1) {
|
||||
var ac = autoclickers.get(wvContents.id);
|
||||
if (ac) ac.vk.kickDisconnected();
|
||||
}
|
||||
if (msg.indexOf('[BOT] VKCalls: call link:') !== -1) {
|
||||
var link = msg.split('[BOT] VKCalls: call link:')[1].trim();
|
||||
console.log('[MAIN] VK call link captured:', link);
|
||||
|
||||
var foundPeerId = null;
|
||||
tabs.forEach(function(t, id) {
|
||||
if (botTabs.has(id) && t.platform === 'vk') {
|
||||
foundPeerId = t.peerId;
|
||||
}
|
||||
});
|
||||
|
||||
if (foundPeerId && botManager) {
|
||||
console.log('[MAIN] Sending VK link to peer:', foundPeerId);
|
||||
botManager.sendMessage(foundPeerId, 'Call created!\n ' + link);
|
||||
}
|
||||
}
|
||||
|
||||
if (msg.indexOf('[BOT] Telemost: call link:') !== -1) {
|
||||
var link = msg.split('[BOT] Telemost: call link:')[1].trim();
|
||||
console.log('[MAIN] Telemost call link captured:', link);
|
||||
|
||||
var foundPeerId = null;
|
||||
tabs.forEach(function(t, id) {
|
||||
if (botTabs.has(id) && t.platform === 'telemost') {
|
||||
foundPeerId = t.peerId;
|
||||
}
|
||||
});
|
||||
|
||||
if (foundPeerId && botManager) {
|
||||
console.log('[MAIN] Sending Telemost link to peer:', foundPeerId);
|
||||
botManager.sendMessage(foundPeerId, 'Call created!\n ' + link);
|
||||
}
|
||||
}
|
||||
|
||||
if (msg.indexOf('[CALL_STATUS]') !== -1) {
|
||||
console.log('[MAIN] Received call status:', msg);
|
||||
if (msg.indexOf(':') !== -1) {
|
||||
var parts = msg.split('[CALL_STATUS] ')[1];
|
||||
var colonIndex = parts.indexOf(':');
|
||||
if (colonIndex !== -1) {
|
||||
var tabId = parts.substring(0, colonIndex);
|
||||
var status = parts.substring(colonIndex + 1);
|
||||
callStatusCache.set(tabId, status);
|
||||
console.log('[MAIN] Cached status for', tabId, ':', status);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
wvContents.on('destroyed', function() {
|
||||
var ac = autoclickers.get(wvContents.id);
|
||||
if (ac) { ac.telemost.stop(); ac.vk.stop(); autoclickers.delete(wvContents.id); }
|
||||
callStatusCache.forEach(function(status, tabId) {
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ipcMain.handle('get-hook-code', async function(e, tabId, url) {
|
||||
var tab = await getTab(tabId);
|
||||
return loadHook(url, tab);
|
||||
});
|
||||
|
||||
ipcMain.handle('get-call-creator-code', function(e, scriptFile) {
|
||||
var filePath = path.join(__dirname, scriptFile || 'vk-call-creator.js');
|
||||
return fs.readFileSync(filePath, 'utf8');
|
||||
});
|
||||
|
||||
ipcMain.handle('set-tunnel-mode', function(e, tabId, mode) {
|
||||
var tab = tabs.get(tabId);
|
||||
if (!tab) return;
|
||||
if (['dc', 'pion-video'].indexOf(mode) === -1) return;
|
||||
tab.tunnelMode = mode;
|
||||
if (tab.relay) killRelay(tab);
|
||||
setTimeout(function() { startRelay(tab); }, 500);
|
||||
});
|
||||
|
||||
ipcMain.handle('start-relay', async function(e, tabId) {
|
||||
var tab = await getTab(tabId);
|
||||
startRelay(tab);
|
||||
});
|
||||
|
||||
ipcMain.handle('start-headless', async function(e, tabId) {
|
||||
var tab = await getTab(tabId);
|
||||
tab.tunnelMode = 'headless-vk';
|
||||
var cookieStr = await getVKCookieString();
|
||||
if (!cookieStr) {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('relay-log', { tabId: tabId, msg: 'No VK cookies found. Please log into VK first.' });
|
||||
}
|
||||
return;
|
||||
}
|
||||
killRelay(tab);
|
||||
var args = ['--cookie-string', cookieStr, '--resources', 'default'];
|
||||
var proc = spawn(headlessPath, args, { stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
tab.relay = proc;
|
||||
var onData = function(data) {
|
||||
data.toString().trim().split('\n').forEach(function(msg) {
|
||||
if (!msg) return;
|
||||
console.log('[headless:' + tabId + ']', msg);
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('relay-log', { tabId: tabId, msg: msg });
|
||||
}
|
||||
});
|
||||
};
|
||||
proc.stdout.on('data', onData);
|
||||
proc.stderr.on('data', onData);
|
||||
proc.on('close', function(code) {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('relay-log', { tabId: tabId, msg: 'Headless exited with code ' + code });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.handle('close-tab', function(e, tabId) {
|
||||
var tab = tabs.get(tabId);
|
||||
if (tab) {
|
||||
killRelay(tab);
|
||||
tabs.delete(tabId);
|
||||
}
|
||||
botTabs.delete(tabId);
|
||||
});
|
||||
|
||||
// Bot IPC
|
||||
ipcMain.handle('start-bot', function(e, settings) {
|
||||
if (botManager) {
|
||||
botManager.stop();
|
||||
}
|
||||
botManager = new BotManager(settings, async function(tabConfig) {
|
||||
if (!mainWindow || mainWindow.isDestroyed()) return;
|
||||
|
||||
var tabId = 'bot-tab-' + Date.now();
|
||||
var ports = await allocPorts();
|
||||
tabs.set(tabId, { relay: null, tunnelMode: tabConfig.mode, platform: tabConfig.platform || 'vk', dcPort: ports.dc, pionPort: ports.pion, peerId: tabConfig.peerId, isBot: true });
|
||||
botTabs.add(tabId);
|
||||
|
||||
mainWindow.webContents.send('create-bot-tab', { tabId: tabId, mode: tabConfig.mode, peerId: tabConfig.peerId, platform: tabConfig.platform || 'vk' });
|
||||
console.log('[BOT] Created tab:', tabId, 'mode:', tabConfig.mode, 'platform:', tabConfig.platform, 'peerId:', tabConfig.peerId);
|
||||
}, function() {
|
||||
var result = [];
|
||||
tabs.forEach(function(tab, tabId) {
|
||||
result.push({
|
||||
id: tabId,
|
||||
platform: tab.platform,
|
||||
mode: tab.tunnelMode,
|
||||
isBot: tab.isBot === true,
|
||||
callStatus: callStatusCache.get(tabId) || 'inactive'
|
||||
});
|
||||
});
|
||||
return result;
|
||||
}, function(tabId) {
|
||||
var tab = tabs.get(tabId);
|
||||
if (tab) {
|
||||
killRelay(tab);
|
||||
tabs.delete(tabId);
|
||||
botTabs.delete(tabId);
|
||||
callStatusCache.delete(tabId);
|
||||
console.log('[BOT] Closed tab:', tabId);
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('close-bot-tab', { tabId: tabId });
|
||||
}
|
||||
}
|
||||
});
|
||||
botManager.onError = function(msg) {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('bot-error', msg);
|
||||
}
|
||||
};
|
||||
botManager.start();
|
||||
return { success: true };
|
||||
});
|
||||
|
||||
ipcMain.handle('stop-bot', function() {
|
||||
if (botManager) {
|
||||
botManager.stop();
|
||||
botManager = null;
|
||||
}
|
||||
return { success: true };
|
||||
});
|
||||
|
||||
ipcMain.handle('get-cookies', async function(e, domain) {
|
||||
var ses = session.fromPartition('persist:creator');
|
||||
var all = await ses.cookies.get({});
|
||||
var vkCookies = all.filter(function(c) {
|
||||
return c.domain && (c.domain.indexOf('vk.com') !== -1 || c.domain.indexOf('vk.ru') !== -1);
|
||||
});
|
||||
console.log('[COOKIES] total:', all.length, 'vk:', vkCookies.length);
|
||||
return vkCookies;
|
||||
});
|
||||
|
||||
|
||||
app.whenReady().then(createWindow);
|
||||
|
||||
app.on('window-all-closed', function() { killAllRelays(); app.quit(); });
|
||||
app.on('before-quit', killAllRelays);
|
||||
process.on('exit', killAllRelays);
|
||||
process.on('SIGINT', function() { killAllRelays(); process.exit(); });
|
||||
process.on('SIGTERM', function() { killAllRelays(); process.exit(); });
|
||||
Generated
+30
-6
@@ -1,18 +1,21 @@
|
||||
{
|
||||
"name": "whitelist-bypass-creator",
|
||||
"version": "0.1.9",
|
||||
"version": "0.2.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "whitelist-bypass-creator",
|
||||
"version": "0.1.9",
|
||||
"version": "0.2.0",
|
||||
"dependencies": {
|
||||
"node-fetch": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/node-fetch": "^2.6.13",
|
||||
"electron": "^33.0.0",
|
||||
"electron-builder": "^25.0.0"
|
||||
"electron-builder": "^25.0.0",
|
||||
"typescript": "^5.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@develar/schema-utils": {
|
||||
@@ -736,15 +739,26 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.19.37",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.37.tgz",
|
||||
"integrity": "sha512-8kzdPJ3FsNsVIurqBs7oodNnCEVbni9yUEkaHbgptDACOPW04jimGagZ51E6+lXUwJjgnBw+hyko/lkFWCldqw==",
|
||||
"version": "22.19.17",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.17.tgz",
|
||||
"integrity": "sha512-wGdMcf+vPYM6jikpS/qhg6WiqSV/OhG+jeeHT/KlVqxYfD40iYJf9/AE1uQxVWFvU7MipKRkRv8NSHiCGgPr8Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node-fetch": {
|
||||
"version": "2.6.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.13.tgz",
|
||||
"integrity": "sha512-QGpRVpzSaUs30JBSGPjOg4Uveu384erbHBoT1zeONvyCfwQxIkUshLAOqN/k9EjGviPRmWTTe6aH2qySWKTVSw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"form-data": "^4.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/plist": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/plist/-/plist-3.0.5.tgz",
|
||||
@@ -2406,6 +2420,16 @@
|
||||
"node": ">= 10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/electron/node_modules/@types/node": {
|
||||
"version": "20.19.39",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.39.tgz",
|
||||
"integrity": "sha512-orrrD74MBUyK8jOAD/r0+lfa1I2MO6I+vAkmAWzMYbCcgrN4lCrmK52gRFQq/JRxfYPfonkr4b0jcY7Olqdqbw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/emoji-regex": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
|
||||
+68
-15
@@ -1,17 +1,21 @@
|
||||
{
|
||||
"name": "whitelist-bypass-creator",
|
||||
"version": "0.1.9",
|
||||
"main": "main.js",
|
||||
"version": "0.2.0",
|
||||
"main": "dist/main/index.js",
|
||||
"scripts": {
|
||||
"start": "electron .",
|
||||
"build": "electron-builder"
|
||||
"build": "tsc",
|
||||
"start": "tsc && electron .",
|
||||
"start:dev": "electron ."
|
||||
},
|
||||
"dependencies": {
|
||||
"node-fetch": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/node-fetch": "^2.6.13",
|
||||
"electron": "^33.0.0",
|
||||
"electron-builder": "^25.0.0"
|
||||
"electron-builder": "^25.0.0",
|
||||
"typescript": "^5.6.0"
|
||||
},
|
||||
"build": {
|
||||
"appId": "whitelist.bypass.creator",
|
||||
@@ -19,18 +23,47 @@
|
||||
"directories": {
|
||||
"output": "../prebuilts"
|
||||
},
|
||||
"files": [
|
||||
"dist/**/*",
|
||||
"index.html",
|
||||
"styles/**/*",
|
||||
"scripts/**/*",
|
||||
"resources/**/*"
|
||||
],
|
||||
"extraResources": [
|
||||
{ "from": "../hooks/dc-creator-vk.js", "to": "hooks/dc-creator-vk.js" },
|
||||
{ "from": "../hooks/dc-creator-telemost.js", "to": "hooks/dc-creator-telemost.js" },
|
||||
{ "from": "../hooks/video-vk.js", "to": "hooks/video-vk.js" },
|
||||
{ "from": "../hooks/video-telemost.js", "to": "hooks/video-telemost.js" }
|
||||
{
|
||||
"from": "../hooks/dc-creator-vk.js",
|
||||
"to": "hooks/dc-creator-vk.js"
|
||||
},
|
||||
{
|
||||
"from": "../hooks/dc-creator-telemost.js",
|
||||
"to": "hooks/dc-creator-telemost.js"
|
||||
},
|
||||
{
|
||||
"from": "../hooks/video-vk.js",
|
||||
"to": "hooks/video-vk.js"
|
||||
},
|
||||
{
|
||||
"from": "../hooks/video-telemost.js",
|
||||
"to": "hooks/video-telemost.js"
|
||||
}
|
||||
],
|
||||
"mac": {
|
||||
"target": "dmg",
|
||||
"icon": "resources/icon.icns",
|
||||
"extraResources": [
|
||||
{ "from": "../relay/relay-darwin", "to": "relay" },
|
||||
{ "from": "../headless/headless-darwin", "to": "headless-creator" }
|
||||
{
|
||||
"from": "../relay/relay-darwin",
|
||||
"to": "relay"
|
||||
},
|
||||
{
|
||||
"from": "../headless/headless-vk-darwin",
|
||||
"to": "headless-vk-creator"
|
||||
},
|
||||
{
|
||||
"from": "../headless/headless-telemost-darwin",
|
||||
"to": "headless-telemost-creator"
|
||||
}
|
||||
]
|
||||
},
|
||||
"win": {
|
||||
@@ -38,16 +71,36 @@
|
||||
"artifactName": "${productName}-${version}-${arch}.${ext}",
|
||||
"icon": "resources/icon.ico",
|
||||
"extraResources": [
|
||||
{ "from": "../relay/relay-bundle.exe", "to": "relay.exe" },
|
||||
{ "from": "../headless/headless-bundle.exe", "to": "headless-creator.exe" }
|
||||
{
|
||||
"from": "../relay/relay-bundle.exe",
|
||||
"to": "relay.exe"
|
||||
},
|
||||
{
|
||||
"from": "../headless/headless-vk-bundle.exe",
|
||||
"to": "headless-vk-creator.exe"
|
||||
},
|
||||
{
|
||||
"from": "../headless/headless-telemost-bundle.exe",
|
||||
"to": "headless-telemost-creator.exe"
|
||||
}
|
||||
]
|
||||
},
|
||||
"linux": {
|
||||
"target": "AppImage",
|
||||
"icon": "resources/icon.png",
|
||||
"extraResources": [
|
||||
{ "from": "../relay/relay-bundle", "to": "relay" },
|
||||
{ "from": "../headless/headless-bundle", "to": "headless-creator" }
|
||||
{
|
||||
"from": "../relay/relay-bundle",
|
||||
"to": "relay"
|
||||
},
|
||||
{
|
||||
"from": "../headless/headless-vk-bundle",
|
||||
"to": "headless-vk-creator"
|
||||
},
|
||||
{
|
||||
"from": "../headless/headless-telemost-bundle",
|
||||
"to": "headless-telemost-creator"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
const { contextBridge, ipcRenderer } = require('electron');
|
||||
|
||||
contextBridge.exposeInMainWorld('bridge', {
|
||||
onRelayLog: function(cb) { ipcRenderer.on('relay-log', function(e, data) { cb(data.tabId, data.msg); }); },
|
||||
getHookCode: function(tabId, url) { return ipcRenderer.invoke('get-hook-code', tabId, url); },
|
||||
setTunnelMode: function(tabId, mode) { return ipcRenderer.invoke('set-tunnel-mode', tabId, mode); },
|
||||
startRelay: function(tabId) { return ipcRenderer.invoke('start-relay', tabId); },
|
||||
closeTab: function(tabId) { return ipcRenderer.invoke('close-tab', tabId); },
|
||||
startBot: function(settings) { return ipcRenderer.invoke('start-bot', settings); },
|
||||
stopBot: function() { return ipcRenderer.invoke('stop-bot'); },
|
||||
onCreateBotTab: function(cb) { ipcRenderer.on('create-bot-tab', function(e, data) { cb(data); }); },
|
||||
getCallCreatorCode: function(scriptFile) { return ipcRenderer.invoke('get-call-creator-code', scriptFile); },
|
||||
onBotError: function(cb) { ipcRenderer.on('bot-error', function(e, msg) { cb(msg); }); },
|
||||
getCookies: function(domain) { return ipcRenderer.invoke('get-cookies', domain); },
|
||||
startHeadless: function(tabId) { return ipcRenderer.invoke('start-headless', tabId); },
|
||||
onCloseBotTab: function(cb) { ipcRenderer.on('close-bot-tab', function(e, data) { cb(data); }); }
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
(function() {
|
||||
if (window.__callCheckerStarted) return;
|
||||
window.__callCheckerStarted = true;
|
||||
|
||||
var tabId = window.__CALL_CHECKER_TAB_ID || 'unknown';
|
||||
console.log('[CALL_STATUS] Checker started for ' + tabId);
|
||||
|
||||
var CHECK_INTERVAL = 10000;
|
||||
var INITIAL_DELAY = 10000;
|
||||
|
||||
var VK_LEAVE_SELECTOR = '[data-testid="calls_call_footer_button_leave_call"]';
|
||||
var TM_END_SELECTOR = '[data-testid="end-call-alt-button"]';
|
||||
|
||||
var checkCallStatus = function() {
|
||||
var vkBtn = document.querySelector(VK_LEAVE_SELECTOR);
|
||||
var tmBtn = document.querySelector(TM_END_SELECTOR);
|
||||
var status = (vkBtn || tmBtn) ? 'active' : 'inactive';
|
||||
console.log('[CALL_STATUS] ' + tabId + ':' + status);
|
||||
};
|
||||
|
||||
setTimeout(function() {
|
||||
checkCallStatus();
|
||||
setInterval(checkCallStatus, CHECK_INTERVAL);
|
||||
}, INITIAL_DELAY);
|
||||
})();
|
||||
@@ -0,0 +1,45 @@
|
||||
(function() {
|
||||
if (window.__tmCallCreatorStarted) return;
|
||||
window.__tmCallCreatorStarted = true;
|
||||
|
||||
var CREATE_BUTTON_SELECTOR = '[data-testid="create-call-button"]';
|
||||
var CALL_PATH_MARKER = '/j/';
|
||||
var CHECK_INTERVAL = 300;
|
||||
|
||||
var start = function() {
|
||||
console.log("[BOT] Telemost: DOM ready...");
|
||||
|
||||
var waitAndClick = function(fn) {
|
||||
if (fn()) return;
|
||||
var observer = new MutationObserver(function() {
|
||||
if (fn()) observer.disconnect();
|
||||
});
|
||||
observer.observe(document.body, { childList: true, subtree: true });
|
||||
};
|
||||
|
||||
waitAndClick(function() {
|
||||
var btn = document.querySelector(CREATE_BUTTON_SELECTOR);
|
||||
if (!btn) return false;
|
||||
|
||||
btn.click();
|
||||
console.log("[BOT] Telemost: creating call...");
|
||||
|
||||
var check = setInterval(function() {
|
||||
var url = location.href;
|
||||
if (url.indexOf(CALL_PATH_MARKER) !== -1) {
|
||||
console.log("[BOT] Telemost: call link:", url);
|
||||
window.__CALL_LINK__ = url;
|
||||
clearInterval(check);
|
||||
}
|
||||
}, CHECK_INTERVAL);
|
||||
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", start);
|
||||
} else {
|
||||
start();
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,81 @@
|
||||
(function() {
|
||||
if (window.__callCreatorStarted) return;
|
||||
window.__callCreatorStarted = true;
|
||||
|
||||
var CALL_MENU_TRIGGER_ID = 'call-menu-trigger';
|
||||
var CREATE_CALL_TEXT = 'Создать звонок по';
|
||||
var CALL_IN_PROGRESS_KEY = 'call_in_progress';
|
||||
var VK_CALL_BASE = 'https://vk.com/call/join/';
|
||||
|
||||
var start = function() {
|
||||
console.log("[BOT] VKCalls: DOM ready...");
|
||||
|
||||
var waitAndClick = function(fn) {
|
||||
if (fn()) return;
|
||||
var observer = new MutationObserver(function() {
|
||||
if (fn()) observer.disconnect();
|
||||
});
|
||||
observer.observe(document.body, { childList: true, subtree: true });
|
||||
};
|
||||
|
||||
waitAndClick(function() {
|
||||
var trigger = document.getElementById(CALL_MENU_TRIGGER_ID);
|
||||
if (!trigger) return false;
|
||||
|
||||
trigger.click();
|
||||
console.log("[BOT] VKCalls: opened call menu");
|
||||
|
||||
waitAndClick(function() {
|
||||
var spans = document.querySelectorAll('span');
|
||||
var el = null;
|
||||
for (var i = 0; i < spans.length; i++) {
|
||||
if (spans[i].textContent.indexOf(CREATE_CALL_TEXT) !== -1) {
|
||||
el = spans[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
var btn = el ? (el.closest('button') || el.closest('div')) : null;
|
||||
if (!btn) return false;
|
||||
|
||||
btn.click();
|
||||
console.log("[BOT] VKCalls: created call");
|
||||
|
||||
var origFetch = window.fetch;
|
||||
window.fetch = function() {
|
||||
var args = arguments;
|
||||
return origFetch.apply(window, args).then(function(res) {
|
||||
if (window.__CALL_LINK_CAPTURED__) return res;
|
||||
try {
|
||||
var clone = res.clone();
|
||||
clone.text().then(function(text) {
|
||||
if (text.indexOf(CALL_IN_PROGRESS_KEY) === -1) return;
|
||||
var json = JSON.parse(text);
|
||||
var items = json && json.response && json.response[1] && json.response[1].items;
|
||||
if (!items) return;
|
||||
for (var j = 0; j < items.length; j++) {
|
||||
var join = items[j] && items[j].call_in_progress && items[j].call_in_progress.join_link;
|
||||
if (join) {
|
||||
var link = VK_CALL_BASE + join;
|
||||
console.log("[BOT] VKCalls: call link:", link);
|
||||
window.__CALL_LINK__ = link;
|
||||
window.__CALL_LINK_CAPTURED__ = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (e) {}
|
||||
return res;
|
||||
});
|
||||
};
|
||||
return true;
|
||||
});
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", start);
|
||||
} else {
|
||||
start();
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,101 @@
|
||||
import { SCAN_INTERVAL_MS, KICK_DELAY_MS, Selector } from '../constants';
|
||||
|
||||
export class TelemostAutoclick {
|
||||
private interval: ReturnType<typeof setInterval> | null = null;
|
||||
private wvContents: Electron.WebContents | null = null;
|
||||
|
||||
attach(wvContents: Electron.WebContents): void {
|
||||
this.stop();
|
||||
this.wvContents = wvContents;
|
||||
this.interval = setInterval(() => this.scan(), SCAN_INTERVAL_MS);
|
||||
wvContents.on('destroyed', () => this.stop());
|
||||
}
|
||||
|
||||
stop(): void {
|
||||
if (this.interval) {
|
||||
clearInterval(this.interval);
|
||||
this.interval = null;
|
||||
}
|
||||
this.wvContents = null;
|
||||
}
|
||||
|
||||
private scan(): void {
|
||||
if (!this.wvContents) return;
|
||||
try {
|
||||
this.wvContents.mainFrame.framesInSubtree.forEach((frame) => {
|
||||
(frame
|
||||
.executeJavaScript(
|
||||
`(function() {
|
||||
var buttons = document.querySelectorAll('.Orb-Button, button, [role="button"], [role="link"]');
|
||||
var admitBtn = null;
|
||||
for (var i = 0; i < buttons.length; i++) {
|
||||
var txt = buttons[i].textContent.replace(/\\s+/g, ' ').trim();
|
||||
if (txt.indexOf('Впустить') !== -1) {
|
||||
admitBtn = buttons[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!admitBtn) return 'idle';
|
||||
var names = document.querySelectorAll('[class*="participantName"]');
|
||||
for (var j = 0; j < names.length; j++) {
|
||||
if (names[j].closest('[class*="selfView"]')) continue;
|
||||
var moreBtn = names[j].querySelector('${Selector.TM_MODERATION_POPUP}');
|
||||
if (moreBtn) {
|
||||
moreBtn.click();
|
||||
return 'kick-open';
|
||||
}
|
||||
}
|
||||
admitBtn.click();
|
||||
return 'admitted';
|
||||
})()`,
|
||||
) as Promise<string>)
|
||||
.then((result) => {
|
||||
if (result ==='kick-open') {
|
||||
setTimeout(() => this.clickRemove(frame), KICK_DELAY_MS);
|
||||
} else if (result ==='admitted') {
|
||||
console.log('[auto-accept] guest admitted');
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
});
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
private clickRemove(frame: Electron.WebFrameMain): void {
|
||||
(frame
|
||||
.executeJavaScript(
|
||||
`(function() {
|
||||
var el = document.querySelector('[title="Удалить со встречи"]');
|
||||
if (el) { el.click(); return true; }
|
||||
return false;
|
||||
})()`,
|
||||
) as Promise<boolean>)
|
||||
.then((result) => {
|
||||
if (result) setTimeout(() => this.confirmRemove(frame), KICK_DELAY_MS);
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
private confirmRemove(frame: Electron.WebFrameMain): void {
|
||||
(frame
|
||||
.executeJavaScript(
|
||||
`(function() {
|
||||
var modal = document.querySelector('${Selector.TM_MODAL}');
|
||||
if (!modal) return false;
|
||||
var btns = modal.querySelectorAll('button');
|
||||
for (var i = 0; i < btns.length; i++) {
|
||||
var txt = btns[i].textContent.replace(/\\s+/g, ' ').trim();
|
||||
if (txt === 'Удалить') {
|
||||
btns[i].click();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
})()`,
|
||||
) as Promise<boolean>)
|
||||
.then((result) => {
|
||||
if (result) console.log('[auto-accept] kicked previous participant');
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
import { SCAN_INTERVAL_MS, KICK_DELAY_MS, Selector } from '../constants';
|
||||
|
||||
export class VkAutoclick {
|
||||
private interval: ReturnType<typeof setInterval> | null = null;
|
||||
private wvContents: Electron.WebContents | null = null;
|
||||
|
||||
attach(wvContents: Electron.WebContents): void {
|
||||
this.stop();
|
||||
this.wvContents = wvContents;
|
||||
this.interval = setInterval(() => this.scan(), SCAN_INTERVAL_MS);
|
||||
wvContents.on('destroyed', () => this.stop());
|
||||
}
|
||||
|
||||
stop(): void {
|
||||
if (this.interval) {
|
||||
clearInterval(this.interval);
|
||||
this.interval = null;
|
||||
}
|
||||
this.wvContents = null;
|
||||
}
|
||||
|
||||
private scan(): void {
|
||||
if (!this.wvContents) return;
|
||||
try {
|
||||
this.wvContents.mainFrame.framesInSubtree.forEach((frame) => {
|
||||
(frame
|
||||
.executeJavaScript(
|
||||
`(function() {
|
||||
var admitBtn = document.querySelector('${Selector.VK_ADMIT}');
|
||||
if (!admitBtn) return 'idle';
|
||||
var menuBtns = document.querySelectorAll('${Selector.VK_PARTICIPANT_MENU}');
|
||||
if (menuBtns.length > 1) {
|
||||
menuBtns[menuBtns.length - 1].click();
|
||||
return 'kick-open';
|
||||
}
|
||||
admitBtn.click();
|
||||
return 'admitted';
|
||||
})()`,
|
||||
) as Promise<string>)
|
||||
.then((result) => {
|
||||
if (result ==='kick-open') {
|
||||
setTimeout(() => this.clickKick(frame), KICK_DELAY_MS);
|
||||
} else if (result ==='admitted') {
|
||||
console.log('[auto-accept] VK guest admitted');
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
});
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
private clickKick(frame: Electron.WebFrameMain): void {
|
||||
(frame
|
||||
.executeJavaScript(
|
||||
`(function() {
|
||||
var btn = document.querySelector('${Selector.VK_KICK}');
|
||||
if (btn) { btn.click(); return true; }
|
||||
return false;
|
||||
})()`,
|
||||
) as Promise<boolean>)
|
||||
.then((result) => {
|
||||
if (result) setTimeout(() => this.confirmKick(frame), KICK_DELAY_MS);
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
private confirmKick(frame: Electron.WebFrameMain): void {
|
||||
(frame
|
||||
.executeJavaScript(
|
||||
`(function() {
|
||||
var btn = document.querySelector('${Selector.VK_KICK_CONFIRM}');
|
||||
if (btn) { btn.click(); return true; }
|
||||
return false;
|
||||
})()`,
|
||||
) as Promise<boolean>)
|
||||
.then((result) => {
|
||||
if (result) console.log('[auto-accept] VK kicked previous participant');
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
kickDisconnected(): void {
|
||||
if (!this.wvContents) return;
|
||||
try {
|
||||
this.wvContents.mainFrame.framesInSubtree.forEach((frame) => {
|
||||
(frame
|
||||
.executeJavaScript(
|
||||
`(function() {
|
||||
var menuBtns = document.querySelectorAll('${Selector.VK_PARTICIPANT_MENU}');
|
||||
var menuBtn = menuBtns.length > 1 ? menuBtns[menuBtns.length - 1] : null;
|
||||
if (menuBtn) { menuBtn.click(); return true; }
|
||||
return false;
|
||||
})()`,
|
||||
) as Promise<boolean>)
|
||||
.then((result) => {
|
||||
if (result) setTimeout(() => this.clickKick(frame), KICK_DELAY_MS);
|
||||
})
|
||||
.catch(() => {});
|
||||
});
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
import fetch from 'node-fetch';
|
||||
import { BotSettings, TabConfig, TabListEntry, TunnelMode, Platform, BotCommand } from '../types';
|
||||
import { VK_API_VERSION, VK_API_BASE_URL, BOT_POLL_RETRY_DELAY_MS, BOT_POLL_WAIT_SECONDS } from '../constants';
|
||||
import {
|
||||
createMainKeyboard,
|
||||
createListKeyboard,
|
||||
findTabByShortId,
|
||||
generateShortId,
|
||||
padShortId,
|
||||
} from './keyboard';
|
||||
|
||||
type CreateTabFn = (config: TabConfig) => Promise<void> | void;
|
||||
type GetTabsFn = () => TabListEntry[];
|
||||
type CloseTabFn = (tabId: string) => void;
|
||||
|
||||
interface VkApiError {
|
||||
error_code: number;
|
||||
error_msg?: string;
|
||||
request_params?: unknown[];
|
||||
}
|
||||
|
||||
interface VkApiResponse {
|
||||
response?: any;
|
||||
error?: VkApiError;
|
||||
}
|
||||
|
||||
interface LongPollData {
|
||||
ts?: string;
|
||||
failed?: number;
|
||||
updates?: any[];
|
||||
}
|
||||
|
||||
interface VkMessage {
|
||||
text?: string;
|
||||
from_id: number;
|
||||
peer_id: number;
|
||||
payload?: string;
|
||||
}
|
||||
|
||||
interface ButtonPayload {
|
||||
cmd: BotCommand;
|
||||
mode?: string;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export class BotManager {
|
||||
private settings: BotSettings;
|
||||
private onCreateTab: CreateTabFn;
|
||||
private onGetTabs: GetTabsFn;
|
||||
private onCloseTab: CloseTabFn;
|
||||
private ts: string | null = null;
|
||||
private key: string | null = null;
|
||||
private server: string | null = null;
|
||||
private running = false;
|
||||
onError: ((msg: string) => void) | null = null;
|
||||
|
||||
constructor(
|
||||
settings: BotSettings,
|
||||
onCreateTab: CreateTabFn,
|
||||
onGetTabs: GetTabsFn,
|
||||
onCloseTab: CloseTabFn,
|
||||
) {
|
||||
this.settings = settings;
|
||||
this.onCreateTab = onCreateTab;
|
||||
this.onGetTabs = onGetTabs;
|
||||
this.onCloseTab = onCloseTab;
|
||||
}
|
||||
|
||||
private async api(method: string, params: Record<string, any> = {}): Promise<any> {
|
||||
params.v = VK_API_VERSION;
|
||||
params.access_token = this.settings.token;
|
||||
const url = new URL(`${VK_API_BASE_URL}/${method}`);
|
||||
Object.keys(params).forEach((k) => url.searchParams.set(k, String(params[k])));
|
||||
const res = await fetch(url.toString());
|
||||
const data = (await res.json()) as VkApiResponse;
|
||||
if (data.error) {
|
||||
const err = data.error;
|
||||
const errMsg =
|
||||
`${method} code: ${err.error_code} msg: ${err.error_msg || 'VK API error'}` +
|
||||
` params: ${JSON.stringify(err.request_params || [])}`;
|
||||
console.error('[BOT] API error:', errMsg);
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
return data.response;
|
||||
}
|
||||
|
||||
private async getLongPollServer(): Promise<void> {
|
||||
const data = await this.api('groups.getLongPollServer', {
|
||||
group_id: parseInt(this.settings.groupId, 10),
|
||||
});
|
||||
this.server = data.server;
|
||||
this.key = data.key;
|
||||
this.ts = data.ts;
|
||||
}
|
||||
|
||||
async start(): Promise<void> {
|
||||
this.running = true;
|
||||
console.log('[BOT] Starting with settings:', this.settings);
|
||||
try {
|
||||
await this.getLongPollServer();
|
||||
console.log('[BOT] LongPoll server:', this.server);
|
||||
this.pollLoop();
|
||||
} catch (err: any) {
|
||||
console.error('[BOT] Failed to start:', err.message);
|
||||
this.running = false;
|
||||
if (this.onError) this.onError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
stop(): void {
|
||||
this.running = false;
|
||||
console.log('[BOT] Stopped');
|
||||
}
|
||||
|
||||
private async pollLoop(): Promise<void> {
|
||||
while (this.running) {
|
||||
try {
|
||||
const url = `${this.server}?act=a_check&key=${this.key}&ts=${this.ts}&wait=${BOT_POLL_WAIT_SECONDS}`;
|
||||
const res = await fetch(url);
|
||||
const data = (await res.json()) as LongPollData;
|
||||
if (data.failed) {
|
||||
console.log('[BOT] LongPoll failed, reconnecting...');
|
||||
await this.getLongPollServer();
|
||||
continue;
|
||||
}
|
||||
this.ts = data.ts || this.ts;
|
||||
for (const update of data.updates || []) {
|
||||
await this.handleUpdate(update);
|
||||
}
|
||||
} catch (err: any) {
|
||||
console.error('[BOT] Poll error:', err.message);
|
||||
await new Promise((resolve) => setTimeout(resolve, BOT_POLL_RETRY_DELAY_MS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async handleUpdate(update: any): Promise<void> {
|
||||
if (update.type !== 'message_new') return;
|
||||
|
||||
const message: VkMessage = update.object.message;
|
||||
let text = (message.text || '').trim();
|
||||
const fromId = message.from_id;
|
||||
const peerId = message.peer_id;
|
||||
|
||||
let payload: ButtonPayload | null = null;
|
||||
if (message.payload) {
|
||||
try {
|
||||
payload = JSON.parse(message.payload);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
console.log('[BOT] Message from', fromId, ':', text, 'payload:', payload);
|
||||
|
||||
if (this.settings.userId && fromId.toString() !== this.settings.userId.toString()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (text === '/start' || text === 'start') {
|
||||
await this.showMenu(peerId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (payload?.cmd) {
|
||||
const handled = await this.handlePayloadCommand(payload, peerId);
|
||||
if (handled) return;
|
||||
if (payload.cmd === BotCommand.VK) {
|
||||
text = '/vk' + (payload.mode === 'video' ? ' video' : '');
|
||||
} else if (payload.cmd === BotCommand.TM) {
|
||||
text = '/tm' + (payload.mode === 'video' ? ' video' : '');
|
||||
}
|
||||
}
|
||||
|
||||
await this.handleTextCommand(text, peerId);
|
||||
}
|
||||
|
||||
private async handlePayloadCommand(payload: ButtonPayload, peerId: number): Promise<boolean> {
|
||||
if (payload.cmd === BotCommand.List) {
|
||||
await this.showList(peerId);
|
||||
return true;
|
||||
}
|
||||
if (payload.cmd === BotCommand.Menu) {
|
||||
await this.showMenu(peerId);
|
||||
return true;
|
||||
}
|
||||
if (payload.cmd === BotCommand.Close && payload.id) {
|
||||
const tabsList = this.onGetTabs();
|
||||
const tab = tabsList.find((entry) => entry.id === payload.id);
|
||||
if (tab) {
|
||||
const shortId = padShortId(generateShortId(tab.id));
|
||||
this.onCloseTab(tab.id);
|
||||
await this.sendMessage(peerId, `${tab.platform} ${tab.mode} ${shortId} closed`, createMainKeyboard());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private async handleTextCommand(text: string, peerId: number): Promise<void> {
|
||||
if (text.startsWith('/vk')) {
|
||||
const mode = text.includes('video') ? TunnelMode.PionVideo : TunnelMode.DC;
|
||||
console.log('[BOT] Creating VK tab with mode:', mode);
|
||||
this.onCreateTab({ mode, peerId, platform: Platform.VK });
|
||||
const label = mode === TunnelMode.DC ? 'DC' : 'Video';
|
||||
await this.sendMessage(peerId, `Creating VK call (${label})`, createMainKeyboard());
|
||||
} else if (text.startsWith('/tm')) {
|
||||
const mode = text.includes('video') ? TunnelMode.PionVideo : TunnelMode.DC;
|
||||
console.log('[BOT] Creating Telemost tab with mode:', mode);
|
||||
this.onCreateTab({ mode, peerId, platform: Platform.Telemost });
|
||||
const label = mode === TunnelMode.DC ? 'DC' : 'Video';
|
||||
await this.sendMessage(peerId, `Creating Telemost call (${label})`, createMainKeyboard());
|
||||
} else if (text === '/list') {
|
||||
await this.showList(peerId);
|
||||
} else if (text.startsWith('/close ')) {
|
||||
const targetShortId = text.split(' ')[1];
|
||||
console.log('[BOT] Close request for ID:', targetShortId);
|
||||
const tabsList = this.onGetTabs();
|
||||
const tab = findTabByShortId(tabsList, targetShortId);
|
||||
if (!tab) {
|
||||
await this.sendMessage(peerId, `Tab ${targetShortId} not found`, createMainKeyboard());
|
||||
} else {
|
||||
this.onCloseTab(tab.id);
|
||||
await this.sendMessage(
|
||||
peerId,
|
||||
`${tab.platform} ${tab.mode} ${targetShortId} closed`,
|
||||
createMainKeyboard(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async sendMessage(peerId: number, text: string, keyboard?: any): Promise<void> {
|
||||
try {
|
||||
const params: Record<string, any> = {
|
||||
peer_id: peerId,
|
||||
message: text,
|
||||
random_id: Math.floor(Math.random() * 1e9),
|
||||
};
|
||||
if (keyboard) {
|
||||
params.keyboard = JSON.stringify(keyboard);
|
||||
}
|
||||
await this.api('messages.send', params);
|
||||
console.log('[BOT] Sent message to', peerId);
|
||||
} catch (err: any) {
|
||||
console.error('[BOT] Send message error:', err.message);
|
||||
}
|
||||
}
|
||||
|
||||
private async showMenu(peerId: number): Promise<void> {
|
||||
await this.sendMessage(peerId, 'Select mode:', createMainKeyboard());
|
||||
}
|
||||
|
||||
private async showList(peerId: number): Promise<void> {
|
||||
const tabsList = this.onGetTabs();
|
||||
if (tabsList.length === 0) {
|
||||
await this.sendMessage(peerId, 'No active tabs', createMainKeyboard());
|
||||
} else {
|
||||
await this.sendMessage(peerId, 'Select tab to close:', createListKeyboard(tabsList));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import { TabListEntry, BotCommand, CallStatus } from '../types';
|
||||
|
||||
export function generateShortId(tabId: string): number {
|
||||
let hash = 0;
|
||||
for (let i = 0; i < tabId.length; i++) {
|
||||
hash = ((hash << 5) - hash) + tabId.charCodeAt(i);
|
||||
hash = hash & hash;
|
||||
}
|
||||
return Math.abs(hash) % 10000;
|
||||
}
|
||||
|
||||
export function padShortId(id: number): string {
|
||||
return ('000' + id).slice(-4);
|
||||
}
|
||||
|
||||
export function findTabByShortId(tabsList: TabListEntry[], shortId: string): TabListEntry | null {
|
||||
const target = parseInt(shortId, 10);
|
||||
for (const tab of tabsList) {
|
||||
if (generateShortId(tab.id) === target) return tab;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function createMainKeyboard() {
|
||||
return {
|
||||
one_time: false,
|
||||
buttons: [
|
||||
[
|
||||
{ action: { type: 'text', label: 'VK DC', payload: JSON.stringify({ cmd: BotCommand.VK, mode: 'dc' }) } },
|
||||
{ action: { type: 'text', label: 'VK Video', payload: JSON.stringify({ cmd: BotCommand.VK, mode: 'video' }) } },
|
||||
],
|
||||
[
|
||||
{ action: { type: 'text', label: 'TM DC', payload: JSON.stringify({ cmd: BotCommand.TM, mode: 'dc' }) } },
|
||||
{ action: { type: 'text', label: 'TM Video', payload: JSON.stringify({ cmd: BotCommand.TM, mode: 'video' }) } },
|
||||
],
|
||||
[
|
||||
{ action: { type: 'text', label: 'Active Tabs', payload: JSON.stringify({ cmd: BotCommand.List }) } },
|
||||
],
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
export function createListKeyboard(tabsList: TabListEntry[]) {
|
||||
const buttons = tabsList.map((entry) => {
|
||||
const shortId = padShortId(generateShortId(entry.id));
|
||||
const prefix = entry.isBot ? 'bot' : 'user';
|
||||
const status = entry.callStatus === CallStatus.Active ? '+' : '-';
|
||||
return [
|
||||
{
|
||||
action: {
|
||||
type: 'text',
|
||||
label: `${prefix} ${entry.platform} ${entry.mode} ${shortId} ${status}`,
|
||||
payload: JSON.stringify({ cmd: BotCommand.Close, id: entry.id }),
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
buttons.push([
|
||||
{ action: { type: 'text', label: 'Back', payload: JSON.stringify({ cmd: BotCommand.Menu }) } },
|
||||
]);
|
||||
return { one_time: false, buttons };
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
export const INITIAL_PORT_BASE = 10000;
|
||||
|
||||
export const SCAN_INTERVAL_MS = 2000;
|
||||
export const KICK_DELAY_MS = 500;
|
||||
export const RELAY_RESTART_DELAY_MS = 500;
|
||||
export const HOOK_POLL_INTERVAL_MS = 500;
|
||||
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 VK_API_VERSION = '5.131';
|
||||
export const VK_API_BASE_URL = 'https://api.vk.com/method';
|
||||
export const VK_IM_URL = 'https://vk.com/im';
|
||||
export const TELEMOST_URL = 'https://telemost.yandex.ru/';
|
||||
|
||||
export const SESSION_PARTITION = 'persist:creator';
|
||||
export const WINDOW_WIDTH = 1200;
|
||||
export const WINDOW_HEIGHT = 800;
|
||||
|
||||
export const USER_AGENT =
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) ' +
|
||||
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';
|
||||
|
||||
export const VK_COOKIE_DOMAINS = ['vk.com', 'vk.ru'];
|
||||
export const YANDEX_COOKIE_DOMAINS = ['yandex.ru', 'yandex.net', 'ya.ru'];
|
||||
|
||||
export enum Selector {
|
||||
VK_ADMIT = '[data-testid="calls_waiting_hall_promote"]',
|
||||
VK_PARTICIPANT_MENU = '[data-testid="calls_participant_list_item_menu_button"]',
|
||||
VK_KICK = '[data-testid="calls_participant_actions_kick"]',
|
||||
VK_KICK_CONFIRM = '[data-testid="calls_call_kick_submit"]',
|
||||
VK_LEAVE_CALL = '[data-testid="calls_call_footer_button_leave_call"]',
|
||||
VK_CALL_MENU_TRIGGER = 'call-menu-trigger',
|
||||
TM_END_CALL = '[data-testid="end-call-alt-button"]',
|
||||
TM_CREATE_CALL = '[data-testid="create-call-button"]',
|
||||
TM_MODERATION_POPUP = '[data-testid="show-moderation-popup"]',
|
||||
TM_MODAL = '[data-testid="orb-modal2"]',
|
||||
}
|
||||
|
||||
export enum IPC {
|
||||
GET_HOOK_CODE = 'get-hook-code',
|
||||
GET_CALL_CREATOR_CODE = 'get-call-creator-code',
|
||||
SET_TUNNEL_MODE = 'set-tunnel-mode',
|
||||
START_RELAY = 'start-relay',
|
||||
START_HEADLESS = 'start-headless',
|
||||
CLOSE_TAB = 'close-tab',
|
||||
START_BOT = 'start-bot',
|
||||
STOP_BOT = 'stop-bot',
|
||||
GET_COOKIES = 'get-cookies',
|
||||
RELAY_LOG = 'relay-log',
|
||||
CREATE_BOT_TAB = 'create-bot-tab',
|
||||
CLOSE_BOT_TAB = 'close-bot-tab',
|
||||
BOT_ERROR = 'bot-error',
|
||||
}
|
||||
|
||||
export const LOG_CAPTURE_SNIPPET = [
|
||||
'if(!window.__logCaptureInstalled){',
|
||||
'window.__logCaptureInstalled=true;',
|
||||
'window.__hookLogs=[];',
|
||||
'var _ol=console.log.bind(console);',
|
||||
'console.log=function(){',
|
||||
'_ol.apply(null,arguments);',
|
||||
"var m=Array.prototype.slice.call(arguments).join(' ');",
|
||||
"if(m.indexOf('[HOOK]')!==-1)window.__hookLogs.push(m)",
|
||||
'}}',
|
||||
].join('');
|
||||
|
||||
export enum HeadlessLogMarker {
|
||||
CALL_CREATED = 'CALL CREATED',
|
||||
JOIN_LINK = 'join_link:',
|
||||
SHORT_LINK = 'short:',
|
||||
TURN = 'TURN:',
|
||||
PROTOCOL = 'protocol:',
|
||||
TUNNEL_CONNECTED = 'TUNNEL CONNECTED',
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { app } from 'electron';
|
||||
import { TabManager } from './tab-manager';
|
||||
import { createWindow } from './window';
|
||||
import { registerIpcHandlers } from './ipc';
|
||||
|
||||
const tabManager = new TabManager();
|
||||
|
||||
registerIpcHandlers(tabManager);
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const win = createWindow(tabManager);
|
||||
tabManager.mainWindow = win;
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
tabManager.killAllRelays();
|
||||
app.quit();
|
||||
});
|
||||
|
||||
app.on('before-quit', () => tabManager.killAllRelays());
|
||||
process.on('exit', () => tabManager.killAllRelays());
|
||||
process.on('SIGINT', () => {
|
||||
tabManager.killAllRelays();
|
||||
process.exit();
|
||||
});
|
||||
process.on('SIGTERM', () => {
|
||||
tabManager.killAllRelays();
|
||||
process.exit();
|
||||
});
|
||||
@@ -0,0 +1,103 @@
|
||||
import { ipcMain, session } from 'electron';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs/promises';
|
||||
import { TabManager } from './tab-manager';
|
||||
import { BotManager } from '../bot/bot-manager';
|
||||
import {
|
||||
IPC,
|
||||
SESSION_PARTITION,
|
||||
VK_COOKIE_DOMAINS,
|
||||
YANDEX_COOKIE_DOMAINS,
|
||||
} from '../constants';
|
||||
import { TunnelMode, Platform, BotSettings } from '../types';
|
||||
|
||||
export function registerIpcHandlers(tabManager: TabManager): void {
|
||||
ipcMain.handle(IPC.GET_HOOK_CODE, async (_e, tabId: string, url: string) => {
|
||||
const tab = await tabManager.getOrCreateTab(tabId);
|
||||
return tabManager.loadHook(tabId, url, tab);
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC.GET_CALL_CREATOR_CODE, async (_e, scriptFile: string) => {
|
||||
const filePath = path.join(__dirname, '..', '..', 'scripts', scriptFile || 'vk-call-creator.js');
|
||||
return fs.readFile(filePath, 'utf8');
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC.SET_TUNNEL_MODE, (_e, tabId: string, mode: string) => {
|
||||
if (!Object.values(TunnelMode).includes(mode as TunnelMode)) return;
|
||||
tabManager.setTunnelMode(tabId, mode as TunnelMode);
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC.START_RELAY, async (_e, tabId: string) => {
|
||||
const tab = await tabManager.getOrCreateTab(tabId);
|
||||
tabManager.startRelay(tabId, tab);
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC.START_HEADLESS, async (_e, tabId: string, platform: string) => {
|
||||
await tabManager.startHeadless(tabId, platform as Platform);
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC.CLOSE_TAB, (_e, tabId: string) => {
|
||||
tabManager.deleteTab(tabId);
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC.START_BOT, (_e, settings: BotSettings) => {
|
||||
if (tabManager.botManager) {
|
||||
tabManager.botManager.stop();
|
||||
}
|
||||
const bm = new BotManager(
|
||||
settings,
|
||||
async (tabConfig) => {
|
||||
if (!tabManager.mainWindow || tabManager.mainWindow.isDestroyed()) return;
|
||||
const tabId = 'bot-tab-' + Date.now();
|
||||
const tab = await tabManager.getOrCreateTab(tabId);
|
||||
tab.tunnelMode = tabConfig.mode;
|
||||
tab.platform = tabConfig.platform || Platform.VK;
|
||||
tab.peerId = tabConfig.peerId;
|
||||
tab.isBot = true;
|
||||
tabManager.addBotTab(tabId);
|
||||
tabManager.mainWindow.webContents.send(IPC.CREATE_BOT_TAB, {
|
||||
tabId,
|
||||
mode: tabConfig.mode,
|
||||
peerId: tabConfig.peerId,
|
||||
platform: tabConfig.platform || Platform.VK,
|
||||
});
|
||||
console.log('[BOT] Created tab:', tabId, 'mode:', tabConfig.mode, 'platform:', tabConfig.platform);
|
||||
},
|
||||
() => tabManager.getTabList(),
|
||||
(tabId) => {
|
||||
tabManager.deleteTab(tabId);
|
||||
console.log('[BOT] Closed tab:', tabId);
|
||||
if (tabManager.mainWindow && !tabManager.mainWindow.isDestroyed()) {
|
||||
tabManager.mainWindow.webContents.send(IPC.CLOSE_BOT_TAB, { tabId });
|
||||
}
|
||||
},
|
||||
);
|
||||
bm.onError = (msg: string) => {
|
||||
if (tabManager.mainWindow && !tabManager.mainWindow.isDestroyed()) {
|
||||
tabManager.mainWindow.webContents.send(IPC.BOT_ERROR, msg);
|
||||
}
|
||||
};
|
||||
tabManager.botManager = bm;
|
||||
bm.start();
|
||||
return { success: true };
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC.STOP_BOT, () => {
|
||||
if (tabManager.botManager) {
|
||||
tabManager.botManager.stop();
|
||||
tabManager.botManager = null;
|
||||
}
|
||||
return { success: true };
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC.GET_COOKIES, async (_e, domain: string) => {
|
||||
const ses = session.fromPartition(SESSION_PARTITION);
|
||||
const all = await ses.cookies.get({});
|
||||
const domains = domain === 'yandex' ? YANDEX_COOKIE_DOMAINS : VK_COOKIE_DOMAINS;
|
||||
const filtered = all.filter((cookie) => {
|
||||
return cookie.domain != null && domains.some((d) => cookie.domain!.includes(d));
|
||||
});
|
||||
console.log(`[COOKIES] total: ${all.length} ${domain}: ${filtered.length}`);
|
||||
return filtered;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
import { app } from 'electron';
|
||||
import { spawn, ChildProcess } from 'child_process';
|
||||
import { BrowserWindow, session } from 'electron';
|
||||
import * as net from 'net';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs/promises';
|
||||
import { TabState, PortPair, TabListEntry, Platform, TunnelMode, RelayMode, CallStatus } from '../types';
|
||||
import {
|
||||
INITIAL_PORT_BASE,
|
||||
IPC,
|
||||
RELAY_RESTART_DELAY_MS,
|
||||
SESSION_PARTITION,
|
||||
VK_COOKIE_DOMAINS,
|
||||
YANDEX_COOKIE_DOMAINS,
|
||||
LOG_CAPTURE_SNIPPET,
|
||||
} from '../constants';
|
||||
import { BotManager } from '../bot/bot-manager';
|
||||
|
||||
function resolveResourcePath(devRelative: string, packedName: string): string {
|
||||
if (app.isPackaged) {
|
||||
return path.join(process.resourcesPath!, packedName);
|
||||
}
|
||||
return path.join(__dirname, '..', '..', '..', devRelative);
|
||||
}
|
||||
|
||||
function binaryName(base: string): string {
|
||||
return process.platform === 'win32' ? base + '.exe' : base;
|
||||
}
|
||||
|
||||
export class TabManager {
|
||||
private tabs = new Map<string, TabState>();
|
||||
private callStatusCache = new Map<string, CallStatus>();
|
||||
private botTabIds = new Set<string>();
|
||||
private nextPortBase = INITIAL_PORT_BASE;
|
||||
private _mainWindow: BrowserWindow | null = null;
|
||||
private _botManager: BotManager | null = null;
|
||||
private relayPath: string;
|
||||
private headlessVKPath: string;
|
||||
private headlessTelemostPath: string;
|
||||
private hooksDir: string;
|
||||
|
||||
constructor() {
|
||||
this.relayPath = resolveResourcePath(
|
||||
path.join('relay', binaryName('relay')),
|
||||
binaryName('relay'),
|
||||
);
|
||||
this.headlessVKPath = resolveResourcePath(
|
||||
path.join('headless', 'vk', binaryName('headless-vk-creator')),
|
||||
binaryName('headless-vk-creator'),
|
||||
);
|
||||
this.headlessTelemostPath = resolveResourcePath(
|
||||
path.join('headless', 'telemost', binaryName('headless-telemost-creator')),
|
||||
binaryName('headless-telemost-creator'),
|
||||
);
|
||||
this.hooksDir = app.isPackaged
|
||||
? path.join(process.resourcesPath!, 'hooks')
|
||||
: path.join(__dirname, '..', '..', '..', 'hooks');
|
||||
}
|
||||
|
||||
get mainWindow(): BrowserWindow | null {
|
||||
return this._mainWindow;
|
||||
}
|
||||
|
||||
set mainWindow(w: BrowserWindow | null) {
|
||||
this._mainWindow = w;
|
||||
}
|
||||
|
||||
get botManager(): BotManager | null {
|
||||
return this._botManager;
|
||||
}
|
||||
|
||||
set botManager(bm: BotManager | null) {
|
||||
this._botManager = bm;
|
||||
}
|
||||
|
||||
private isPortFree(port: number): Promise<boolean> {
|
||||
return new Promise((resolve) => {
|
||||
const server = net.createServer();
|
||||
server.once('error', () => resolve(false));
|
||||
server.once('listening', () => {
|
||||
server.close(() => resolve(true));
|
||||
});
|
||||
server.listen(port, '127.0.0.1');
|
||||
});
|
||||
}
|
||||
|
||||
async allocPorts(): Promise<PortPair> {
|
||||
while (true) {
|
||||
const dc = this.nextPortBase;
|
||||
const pion = this.nextPortBase + 1;
|
||||
this.nextPortBase += 2;
|
||||
if (await this.isPortFree(dc) && await this.isPortFree(pion)) {
|
||||
return { dc, pion };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async getOrCreateTab(tabId: string): Promise<TabState> {
|
||||
if (!this.tabs.has(tabId)) {
|
||||
const ports = await this.allocPorts();
|
||||
this.tabs.set(tabId, {
|
||||
relay: null,
|
||||
tunnelMode: TunnelMode.DC,
|
||||
platform: Platform.VK,
|
||||
dcPort: ports.dc,
|
||||
pionPort: ports.pion,
|
||||
});
|
||||
}
|
||||
return this.tabs.get(tabId)!;
|
||||
}
|
||||
|
||||
getTab(tabId: string): TabState | undefined {
|
||||
return this.tabs.get(tabId);
|
||||
}
|
||||
|
||||
deleteTab(tabId: string): void {
|
||||
const tab = this.tabs.get(tabId);
|
||||
if (tab) {
|
||||
this.killRelay(tabId, tab);
|
||||
this.tabs.delete(tabId);
|
||||
}
|
||||
this.botTabIds.delete(tabId);
|
||||
this.callStatusCache.delete(tabId);
|
||||
}
|
||||
|
||||
addBotTab(tabId: string): void {
|
||||
this.botTabIds.add(tabId);
|
||||
}
|
||||
|
||||
removeBotTab(tabId: string): void {
|
||||
this.botTabIds.delete(tabId);
|
||||
}
|
||||
|
||||
isBotTab(tabId: string): boolean {
|
||||
return this.botTabIds.has(tabId);
|
||||
}
|
||||
|
||||
setCallStatus(tabId: string, status: CallStatus): void {
|
||||
this.callStatusCache.set(tabId, status);
|
||||
}
|
||||
|
||||
getCallStatus(tabId: string): CallStatus {
|
||||
return this.callStatusCache.get(tabId) || CallStatus.Inactive;
|
||||
}
|
||||
|
||||
findBotPeerId(platform: Platform): number | null {
|
||||
for (const [tabId, tab] of this.tabs) {
|
||||
if (this.botTabIds.has(tabId) && tab.platform === platform && tab.peerId != null) {
|
||||
return tab.peerId;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
getTabList(): TabListEntry[] {
|
||||
const result: TabListEntry[] = [];
|
||||
this.tabs.forEach((tab, tabId) => {
|
||||
result.push({
|
||||
id: tabId,
|
||||
platform: tab.platform,
|
||||
mode: tab.tunnelMode,
|
||||
isBot: tab.isBot === true,
|
||||
callStatus: this.getCallStatus(tabId),
|
||||
});
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
private sendLog(tabId: string, msg: string): void {
|
||||
if (this._mainWindow && !this._mainWindow.isDestroyed()) {
|
||||
this._mainWindow.webContents.send(IPC.RELAY_LOG, { tabId, msg });
|
||||
}
|
||||
}
|
||||
|
||||
private attachProcessOutput(proc: ChildProcess, tabId: string): void {
|
||||
const onData = (data: Buffer) => {
|
||||
data
|
||||
.toString()
|
||||
.trim()
|
||||
.split('\n')
|
||||
.forEach((msg) => {
|
||||
if (!msg) return;
|
||||
console.log(`[relay:${tabId}]`, msg);
|
||||
this.sendLog(tabId, msg);
|
||||
});
|
||||
};
|
||||
proc.stdout?.on('data', onData);
|
||||
proc.stderr?.on('data', onData);
|
||||
}
|
||||
|
||||
startRelay(tabId: string, tab: TabState): void {
|
||||
this.killRelay(tabId, tab);
|
||||
const port = tab.tunnelMode === TunnelMode.PionVideo ? tab.pionPort : tab.dcPort;
|
||||
let relayMode: RelayMode = RelayMode.DCCreator;
|
||||
if (tab.tunnelMode === TunnelMode.PionVideo) {
|
||||
relayMode = tab.platform === Platform.Telemost
|
||||
? RelayMode.TelemostVideoCreator
|
||||
: RelayMode.VKVideoCreator;
|
||||
}
|
||||
const proc = spawn(this.relayPath, ['--mode', relayMode, '--ws-port', String(port)], {
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
});
|
||||
tab.relay = proc;
|
||||
this.attachProcessOutput(proc, tabId);
|
||||
proc.on('close', (code) => {
|
||||
this.sendLog(tabId, `Relay exited with code ${code}`);
|
||||
});
|
||||
}
|
||||
|
||||
async startHeadless(tabId: string, platform: Platform): Promise<void> {
|
||||
const tab = await this.getOrCreateTab(tabId);
|
||||
const isTelemost = platform === Platform.Telemost;
|
||||
tab.tunnelMode = isTelemost ? TunnelMode.HeadlessTelemost : TunnelMode.HeadlessVK;
|
||||
tab.platform = platform;
|
||||
const cookieStr = isTelemost
|
||||
? await this.getYandexCookieString()
|
||||
: await this.getVKCookieString();
|
||||
if (!cookieStr) {
|
||||
const name = isTelemost ? 'Yandex' : 'VK';
|
||||
this.sendLog(tabId, `No ${name} cookies found. Please log into ${name} first.`);
|
||||
return;
|
||||
}
|
||||
this.killRelay(tabId, tab);
|
||||
const binaryPath = isTelemost ? this.headlessTelemostPath : this.headlessVKPath;
|
||||
const proc = spawn(binaryPath, ['--cookie-string', cookieStr, '--resources', 'default'], {
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
});
|
||||
tab.relay = proc;
|
||||
this.attachProcessOutput(proc, tabId);
|
||||
proc.on('close', (code) => {
|
||||
this.sendLog(tabId, `Headless exited with code ${code}`);
|
||||
});
|
||||
}
|
||||
|
||||
killRelay(tabId: string, tab: TabState): void {
|
||||
if (tab.relay) {
|
||||
console.log(`[${tabId}] killing process pid=${tab.relay.pid}`);
|
||||
tab.relay.kill();
|
||||
tab.relay = null;
|
||||
}
|
||||
}
|
||||
|
||||
killAllRelays(): void {
|
||||
this.tabs.forEach((tab, tabId) => this.killRelay(tabId, tab));
|
||||
}
|
||||
|
||||
async loadHook(tabId: string, url: string, tab: TabState): Promise<string> {
|
||||
const isTelemost = url.includes('telemost.yandex');
|
||||
const newPlatform = isTelemost ? Platform.Telemost : Platform.VK;
|
||||
|
||||
if (newPlatform !== tab.platform && tab.tunnelMode === TunnelMode.PionVideo) {
|
||||
tab.platform = newPlatform;
|
||||
this.killRelay(tabId, tab);
|
||||
setTimeout(() => this.startRelay(tabId, tab), RELAY_RESTART_DELAY_MS);
|
||||
} else {
|
||||
tab.platform = newPlatform;
|
||||
}
|
||||
|
||||
if (tab.tunnelMode === TunnelMode.PionVideo) {
|
||||
const hookFile = isTelemost ? 'video-telemost.js' : 'video-vk.js';
|
||||
const hook = await fs.readFile(path.join(this.hooksDir, hookFile), 'utf8');
|
||||
return LOG_CAPTURE_SNIPPET + `window.PION_PORT=${tab.pionPort};window.IS_CREATOR=true;` + hook;
|
||||
}
|
||||
|
||||
const hookFile = isTelemost ? 'dc-creator-telemost.js' : 'dc-creator-vk.js';
|
||||
const hook = await fs.readFile(path.join(this.hooksDir, hookFile), 'utf8');
|
||||
return LOG_CAPTURE_SNIPPET + `window.WS_PORT=${tab.dcPort};` + hook;
|
||||
}
|
||||
|
||||
setTunnelMode(tabId: string, mode: TunnelMode): void {
|
||||
const tab = this.tabs.get(tabId);
|
||||
if (!tab) return;
|
||||
tab.tunnelMode = mode;
|
||||
this.killRelay(tabId, tab);
|
||||
setTimeout(() => this.startRelay(tabId, tab), RELAY_RESTART_DELAY_MS);
|
||||
}
|
||||
|
||||
async getVKCookieString(): Promise<string> {
|
||||
const ses = session.fromPartition(SESSION_PARTITION);
|
||||
const all = await ses.cookies.get({});
|
||||
const vkCookies = all.filter((cookie) => {
|
||||
return cookie.domain != null && VK_COOKIE_DOMAINS.some((d) => cookie.domain!.includes(d));
|
||||
});
|
||||
return vkCookies.map((cookie) => `${cookie.name}=${cookie.value}`).join('; ');
|
||||
}
|
||||
|
||||
async getYandexCookieString(): Promise<string> {
|
||||
const ses = session.fromPartition(SESSION_PARTITION);
|
||||
const all = await ses.cookies.get({});
|
||||
const yaCookies = all.filter((cookie) => {
|
||||
return cookie.domain != null && YANDEX_COOKIE_DOMAINS.some((d) => cookie.domain!.includes(d));
|
||||
});
|
||||
return yaCookies.map((cookie) => `${cookie.name}=${cookie.value}`).join('; ');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
import { app, BrowserWindow, session, Session } from 'electron';
|
||||
import * as path from 'path';
|
||||
import { TabManager } from './tab-manager';
|
||||
import { VkAutoclick } from '../autoclick/vk';
|
||||
import { TelemostAutoclick } from '../autoclick/telemost';
|
||||
import { SESSION_PARTITION, USER_AGENT, WINDOW_WIDTH, WINDOW_HEIGHT } from '../constants';
|
||||
import { Platform, CallStatus } from '../types';
|
||||
|
||||
function stripCSP(ses: Session): void {
|
||||
ses.webRequest.onHeadersReceived((details, callback) => {
|
||||
const headers = { ...details.responseHeaders };
|
||||
delete headers['content-security-policy'];
|
||||
delete headers['Content-Security-Policy'];
|
||||
delete headers['content-security-policy-report-only'];
|
||||
delete headers['Content-Security-Policy-Report-Only'];
|
||||
callback({ responseHeaders: headers });
|
||||
});
|
||||
}
|
||||
|
||||
function parseCallStatus(msg: string): { tabId: string; status: CallStatus } | null {
|
||||
const prefix = '[CALL_STATUS] ';
|
||||
const idx = msg.indexOf(prefix);
|
||||
if (idx === -1) return null;
|
||||
const parts = msg.substring(idx + prefix.length);
|
||||
const colonIdx = parts.indexOf(':');
|
||||
if (colonIdx === -1) return null;
|
||||
const status = parts.substring(colonIdx + 1);
|
||||
return {
|
||||
tabId: parts.substring(0, colonIdx),
|
||||
status: status === CallStatus.Active ? CallStatus.Active : CallStatus.Inactive,
|
||||
};
|
||||
}
|
||||
|
||||
function extractCallLink(msg: string, prefix: string): string | null {
|
||||
const idx = msg.indexOf(prefix);
|
||||
if (idx === -1) return null;
|
||||
return msg.split(prefix)[1].trim();
|
||||
}
|
||||
|
||||
export function createWindow(tabManager: TabManager): BrowserWindow {
|
||||
const ses = session.fromPartition(SESSION_PARTITION);
|
||||
stripCSP(ses);
|
||||
ses.setPermissionRequestHandler((_wc, _perm, cb) => cb(true));
|
||||
ses.setPermissionCheckHandler(() => true);
|
||||
ses.setUserAgent(USER_AGENT);
|
||||
|
||||
app.on('session-created', stripCSP);
|
||||
|
||||
const win = new BrowserWindow({
|
||||
width: WINDOW_WIDTH,
|
||||
height: WINDOW_HEIGHT,
|
||||
icon: path.join(__dirname, '..', '..', 'resources', 'icon.png'),
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, '..', 'preload', 'index.js'),
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
webviewTag: true,
|
||||
},
|
||||
});
|
||||
|
||||
win.loadFile('index.html');
|
||||
win.on('closed', () => {
|
||||
tabManager.mainWindow = null;
|
||||
});
|
||||
|
||||
const autoclickers = new Map<number, { telemost: TelemostAutoclick; vk: VkAutoclick }>();
|
||||
|
||||
win.webContents.on('did-attach-webview', (_e, wvContents) => {
|
||||
wvContents.on('before-input-event', (_e, input) => {
|
||||
if (input.key === 'F12') wvContents.openDevTools();
|
||||
});
|
||||
|
||||
wvContents.on('did-navigate', (_e, url) => {
|
||||
const wcId = wvContents.id;
|
||||
if (!autoclickers.has(wcId)) {
|
||||
autoclickers.set(wcId, {
|
||||
telemost: new TelemostAutoclick(),
|
||||
vk: new VkAutoclick(),
|
||||
});
|
||||
}
|
||||
const ac = autoclickers.get(wcId)!;
|
||||
if (url.includes('telemost.yandex')) {
|
||||
ac.vk.stop();
|
||||
ac.telemost.attach(wvContents);
|
||||
} else if (url.includes('vk.com')) {
|
||||
ac.telemost.stop();
|
||||
ac.vk.attach(wvContents);
|
||||
} else {
|
||||
ac.telemost.stop();
|
||||
ac.vk.stop();
|
||||
}
|
||||
});
|
||||
|
||||
wvContents.on('console-message', (_e, _level, msg) => {
|
||||
if (msg.includes('state: disconnected') || msg.includes('state: failed')) {
|
||||
const ac = autoclickers.get(wvContents.id);
|
||||
if (ac) ac.vk.kickDisconnected();
|
||||
}
|
||||
|
||||
handleBotCallLink(tabManager, msg, Platform.VK, '[BOT] VKCalls: call link:');
|
||||
handleBotCallLink(tabManager, msg, Platform.Telemost, '[BOT] Telemost: call link:');
|
||||
|
||||
const callStatus = parseCallStatus(msg);
|
||||
if (callStatus) {
|
||||
console.log('[MAIN] Cached status for', callStatus.tabId, ':', callStatus.status);
|
||||
tabManager.setCallStatus(callStatus.tabId, callStatus.status);
|
||||
}
|
||||
});
|
||||
|
||||
wvContents.on('destroyed', () => {
|
||||
const ac = autoclickers.get(wvContents.id);
|
||||
if (ac) {
|
||||
ac.telemost.stop();
|
||||
ac.vk.stop();
|
||||
autoclickers.delete(wvContents.id);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
function handleBotCallLink(
|
||||
tabManager: TabManager,
|
||||
msg: string,
|
||||
platform: Platform,
|
||||
prefix: string,
|
||||
): void {
|
||||
const link = extractCallLink(msg, prefix);
|
||||
if (!link) return;
|
||||
console.log(`[MAIN] ${platform} call link captured:`, link);
|
||||
const peerId = tabManager.findBotPeerId(platform);
|
||||
if (peerId != null && tabManager.botManager) {
|
||||
console.log(`[MAIN] Sending ${platform} link to peer:`, peerId);
|
||||
tabManager.botManager.sendMessage(peerId, `Call created!\n ${link}`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { IPC } from '../constants';
|
||||
|
||||
(window as any).bridge = {
|
||||
onRelayLog(cb: (tabId: string, msg: string) => void) {
|
||||
ipcRenderer.on(IPC.RELAY_LOG, (_e, data) => cb(data.tabId, data.msg));
|
||||
},
|
||||
getHookCode(tabId: string, url: string) {
|
||||
return ipcRenderer.invoke(IPC.GET_HOOK_CODE, tabId, url);
|
||||
},
|
||||
setTunnelMode(tabId: string, mode: string) {
|
||||
return ipcRenderer.invoke(IPC.SET_TUNNEL_MODE, tabId, mode);
|
||||
},
|
||||
startRelay(tabId: string) {
|
||||
return ipcRenderer.invoke(IPC.START_RELAY, tabId);
|
||||
},
|
||||
closeTab(tabId: string) {
|
||||
return ipcRenderer.invoke(IPC.CLOSE_TAB, tabId);
|
||||
},
|
||||
startBot(settings: any) {
|
||||
return ipcRenderer.invoke(IPC.START_BOT, settings);
|
||||
},
|
||||
stopBot() {
|
||||
return ipcRenderer.invoke(IPC.STOP_BOT);
|
||||
},
|
||||
onCreateBotTab(cb: (data: any) => void) {
|
||||
ipcRenderer.on(IPC.CREATE_BOT_TAB, (_e, data) => cb(data));
|
||||
},
|
||||
getCallCreatorCode(scriptFile: string) {
|
||||
return ipcRenderer.invoke(IPC.GET_CALL_CREATOR_CODE, scriptFile);
|
||||
},
|
||||
onBotError(cb: (msg: string) => void) {
|
||||
ipcRenderer.on(IPC.BOT_ERROR, (_e, msg) => cb(msg));
|
||||
},
|
||||
getCookies(domain: string) {
|
||||
return ipcRenderer.invoke(IPC.GET_COOKIES, domain);
|
||||
},
|
||||
startHeadless(tabId: string, platform: string) {
|
||||
return ipcRenderer.invoke(IPC.START_HEADLESS, tabId, platform);
|
||||
},
|
||||
onCloseBotTab(cb: (data: any) => void) {
|
||||
ipcRenderer.on(IPC.CLOSE_BOT_TAB, (_e, data) => cb(data));
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,251 @@
|
||||
import { Platform, Bridge, LogPanel, Webview } from '../types';
|
||||
import { SESSION_PARTITION, HOOK_POLL_INTERVAL_MS, CALL_CREATOR_INJECT_DELAY_MS } from '../constants';
|
||||
import { RendererTabManager } from './tab-manager';
|
||||
|
||||
declare const window: Window & { bridge: Bridge };
|
||||
|
||||
export function renderTabs(tm: RendererTabManager): void {
|
||||
const bar = document.getElementById('tabBar')!;
|
||||
let html = '';
|
||||
Object.keys(tm.tabs).forEach((id) => {
|
||||
const tab = tm.tabs[id];
|
||||
const label = tm.getTabLabel(tab);
|
||||
const cls = id === tm.activeTabId ? 'tab active' : 'tab';
|
||||
html +=
|
||||
`<div class="${cls}" data-tab-id="${id}">` +
|
||||
`<span class="tab-label">${escapeHtml(label)}</span>` +
|
||||
`<img class="edit" src="resources/icons8-pencil-50.png" data-action="rename">` +
|
||||
` <span class="close" data-action="close">✕</span></div>`;
|
||||
});
|
||||
html += '<div class="tab-add" data-action="add-tab" title="New tab">+</div>';
|
||||
bar.innerHTML = html;
|
||||
}
|
||||
|
||||
export function renderContent(tm: RendererTabManager): void {
|
||||
const content = document.getElementById('content')!;
|
||||
const welcome = document.getElementById('welcome')!;
|
||||
const toolbar = document.getElementById('toolbar')!;
|
||||
const logsPanel = document.getElementById('logsPanel')!;
|
||||
const headlessInfo = document.getElementById('headlessInfo')!;
|
||||
|
||||
const webviews = content.querySelectorAll('webview');
|
||||
webviews.forEach((wv) => wv.classList.add('hidden'));
|
||||
|
||||
if (!tm.activeTabId || !tm.tabs[tm.activeTabId]) {
|
||||
welcome.style.display = 'flex';
|
||||
toolbar.style.display = 'none';
|
||||
logsPanel.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
welcome.style.display = 'none';
|
||||
logsPanel.style.display = 'flex';
|
||||
|
||||
const activeTab = tm.tabs[tm.activeTabId];
|
||||
if (activeTab.headless) {
|
||||
toolbar.style.display = 'none';
|
||||
headlessInfo.style.display = 'block';
|
||||
const title = activeTab.platform === Platform.Telemost ? 'Headless Telemost' : 'Headless VK';
|
||||
document.getElementById('headlessTitle')!.textContent = title;
|
||||
document.getElementById('headlessStatus')!.textContent = activeTab.headlessStatus || 'Starting...';
|
||||
const callInfo = activeTab.callInfo;
|
||||
const isTelemost = activeTab.platform === Platform.Telemost;
|
||||
const callInfoVK = document.getElementById('headlessCallInfo')!;
|
||||
const callInfoTM = document.getElementById('headlessCallInfoTM')!;
|
||||
if (callInfo && isTelemost) {
|
||||
callInfoVK.style.display = 'none';
|
||||
callInfoTM.style.display = 'block';
|
||||
document.getElementById('headlessTMJoinLink')!.textContent = callInfo.joinLink || '';
|
||||
document.getElementById('headlessTMProtocol')!.textContent = callInfo.protocol || '';
|
||||
} else if (callInfo) {
|
||||
callInfoTM.style.display = 'none';
|
||||
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 || '';
|
||||
} else {
|
||||
callInfoVK.style.display = 'none';
|
||||
callInfoTM.style.display = 'none';
|
||||
}
|
||||
} else {
|
||||
toolbar.style.display = 'flex';
|
||||
headlessInfo.style.display = 'none';
|
||||
(document.getElementById('modeSelect') as HTMLSelectElement).value = activeTab.mode;
|
||||
if (activeTab.wv) activeTab.wv.classList.remove('hidden');
|
||||
}
|
||||
|
||||
document.getElementById('relayLog')!.textContent = activeTab.relayLogs || '';
|
||||
document.getElementById('hookLog')!.textContent = activeTab.hookLogs || '';
|
||||
scrollLogs();
|
||||
|
||||
renderBotButton(tm);
|
||||
}
|
||||
|
||||
export function renderBotButton(tm: RendererTabManager): void {
|
||||
const btn = document.getElementById('tabBot')!;
|
||||
btn.textContent = tm.botRunning ? 'Bot: On' : 'Bot: Off';
|
||||
btn.classList.toggle('running', tm.botRunning);
|
||||
}
|
||||
|
||||
export function scrollLogs(): void {
|
||||
const relayEl = document.getElementById('relayLog');
|
||||
const hookEl = document.getElementById('hookLog');
|
||||
if (relayEl) relayEl.scrollTop = relayEl.scrollHeight;
|
||||
if (hookEl) hookEl.scrollTop = hookEl.scrollHeight;
|
||||
}
|
||||
|
||||
export function loadURL(tm: RendererTabManager, url: string): void {
|
||||
if (!tm.activeTabId) return;
|
||||
const activeTab = tm.tabs[tm.activeTabId];
|
||||
if (activeTab.wv) activeTab.wv.remove();
|
||||
|
||||
const webview = document.createElement('webview') as unknown as Webview;
|
||||
webview.setAttribute('src', url);
|
||||
webview.setAttribute('partition', SESSION_PARTITION);
|
||||
webview.setAttribute('nodeintegration', '');
|
||||
webview.setAttribute('nodeintegrationinsubframes', '');
|
||||
webview.classList.add('webview-full');
|
||||
webview.dataset.tabId = tm.activeTabId;
|
||||
document.getElementById('content')!.appendChild(webview);
|
||||
|
||||
webview.addEventListener('dom-ready', () => {
|
||||
webview.setAudioMuted(true);
|
||||
const currentTabId = webview.dataset.tabId!;
|
||||
|
||||
window.bridge.getHookCode(currentTabId, webview.getURL()).then((code: string) => {
|
||||
webview.executeJavaScript(code).catch(() => {});
|
||||
});
|
||||
|
||||
window.bridge.getCallCreatorCode('call-checker.js').then((checkerCode: string) => {
|
||||
const inject = `window.__CALL_CHECKER_TAB_ID = "${currentTabId}"; ${checkerCode}`;
|
||||
webview.executeJavaScript(inject).catch(() => {});
|
||||
});
|
||||
|
||||
const tabState = tm.tabs[currentTabId];
|
||||
if (tabState?.isBot) {
|
||||
setTimeout(() => {
|
||||
const scriptFile = tabState.platform === Platform.Telemost ? 'tm-call-creator.js' : 'vk-call-creator.js';
|
||||
window.bridge.getCallCreatorCode(scriptFile).then((code: string) => {
|
||||
webview.executeJavaScript(code).catch(() => {});
|
||||
});
|
||||
}, CALL_CREATOR_INJECT_DELAY_MS);
|
||||
}
|
||||
});
|
||||
|
||||
webview.addEventListener('did-navigate', () => {
|
||||
activeTab.url = webview.getURL() || activeTab.url;
|
||||
renderTabs(tm);
|
||||
const currentTabId = webview.dataset.tabId!;
|
||||
webview.executeJavaScript('window.__hookInstalled = false').catch(() => {});
|
||||
window.bridge.getHookCode(currentTabId, webview.getURL()).then((code: string) => {
|
||||
webview.executeJavaScript(code).catch(() => {});
|
||||
});
|
||||
window.bridge.getCallCreatorCode('call-checker.js').then((checkerCode: string) => {
|
||||
const inject = `window.__CALL_CHECKER_TAB_ID = "${currentTabId}"; ${checkerCode}`;
|
||||
webview.executeJavaScript(inject).catch(() => {});
|
||||
});
|
||||
});
|
||||
|
||||
activeTab.wv = webview;
|
||||
activeTab.url = url;
|
||||
renderTabs(tm);
|
||||
}
|
||||
|
||||
export function startHookLogPoller(tm: RendererTabManager): void {
|
||||
setInterval(() => {
|
||||
if (!tm.activeTabId || !tm.tabs[tm.activeTabId]?.wv) return;
|
||||
const webview = tm.tabs[tm.activeTabId].wv!;
|
||||
webview
|
||||
.executeJavaScript(
|
||||
'(window.__hookLogs && window.__hookLogs.length) ? window.__hookLogs.splice(0) : []',
|
||||
)
|
||||
.then((logs: string[]) => {
|
||||
if (!logs.length) return;
|
||||
const el = document.getElementById('hookLog')!;
|
||||
logs.forEach((msg) => {
|
||||
if (el.textContent!.length > 0) el.textContent += '\n';
|
||||
el.textContent += msg.replace('[HOOK] ', '');
|
||||
});
|
||||
el.scrollTop = el.scrollHeight;
|
||||
})
|
||||
.catch(() => {});
|
||||
}, HOOK_POLL_INTERVAL_MS);
|
||||
}
|
||||
|
||||
function escapeHtml(str: string): string {
|
||||
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
}
|
||||
|
||||
export function showError(msg: string): void {
|
||||
document.getElementById('errorText')!.textContent = msg;
|
||||
document.getElementById('errorPopup')!.classList.add('visible');
|
||||
}
|
||||
|
||||
export function closeError(): void {
|
||||
document.getElementById('errorPopup')!.classList.remove('visible');
|
||||
}
|
||||
|
||||
export function clearLog(panel: LogPanel): void {
|
||||
const id = panel === LogPanel.Relay ? 'relayLog' : 'hookLog';
|
||||
document.getElementById(id)!.textContent = '';
|
||||
}
|
||||
|
||||
export function saveLogs(): void {
|
||||
const relay = document.getElementById('relayLog')!.textContent || '';
|
||||
const hook = document.getElementById('hookLog')!.textContent || '';
|
||||
const text = '=== RELAY ===\n' + relay + '\n\n=== HOOK ===\n' + hook;
|
||||
const blob = new Blob([text], { type: 'text/plain' });
|
||||
const anchor = document.createElement('a');
|
||||
anchor.href = URL.createObjectURL(blob);
|
||||
anchor.download = 'tunnel-logs-' + new Date().toISOString().replace(/[:.]/g, '-') + '.txt';
|
||||
anchor.click();
|
||||
URL.revokeObjectURL(anchor.href);
|
||||
}
|
||||
|
||||
export function exportCookies(domain: string, filename: string, errorMsg: string): void {
|
||||
window.bridge.getCookies(domain).then((cookies) => {
|
||||
if (!cookies.length) {
|
||||
showError(errorMsg);
|
||||
return;
|
||||
}
|
||||
const simple = cookies.map((cookie) => ({ name: cookie.name, value: cookie.value }));
|
||||
const blob = new Blob([JSON.stringify(simple, null, 2)], { type: 'application/json' });
|
||||
const anchor = document.createElement('a');
|
||||
anchor.href = URL.createObjectURL(blob);
|
||||
anchor.download = filename;
|
||||
anchor.click();
|
||||
URL.revokeObjectURL(anchor.href);
|
||||
});
|
||||
}
|
||||
|
||||
export function copyToClipboard(text: string): void {
|
||||
navigator.clipboard.writeText(text);
|
||||
}
|
||||
|
||||
export function renameTab(tm: RendererTabManager, tabId: string, tabEl: HTMLElement): void {
|
||||
const span = tabEl.querySelector('.tab-label') as HTMLElement;
|
||||
if (!span) return;
|
||||
const input = document.createElement('input');
|
||||
input.type = 'text';
|
||||
input.value = tm.tabs[tabId]?.name || '';
|
||||
input.placeholder = tm.getTabLabel(tm.tabs[tabId]);
|
||||
input.className = 'tab-rename-input';
|
||||
span.replaceWith(input);
|
||||
input.focus();
|
||||
input.select();
|
||||
const done = () => {
|
||||
if (tm.tabs[tabId]) {
|
||||
tm.tabs[tabId].name = input.value.trim();
|
||||
}
|
||||
renderTabs(tm);
|
||||
};
|
||||
input.addEventListener('blur', done);
|
||||
input.addEventListener('keydown', (ev) => {
|
||||
if (ev.key === 'Enter') input.blur();
|
||||
if (ev.key === 'Escape') {
|
||||
input.value = '';
|
||||
input.blur();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
import { RendererTabManager } from './tab-manager';
|
||||
import {
|
||||
renderTabs,
|
||||
renderContent,
|
||||
renderBotButton,
|
||||
loadURL,
|
||||
startHookLogPoller,
|
||||
showError,
|
||||
closeError,
|
||||
clearLog,
|
||||
saveLogs,
|
||||
exportCookies,
|
||||
copyToClipboard,
|
||||
renameTab,
|
||||
} from './dom';
|
||||
import { VK_IM_URL, TELEMOST_URL } from '../constants';
|
||||
import { Platform, Bridge, BotTabData, LogPanel, TunnelMode } from '../types';
|
||||
|
||||
declare const window: Window & { bridge: Bridge };
|
||||
|
||||
const tm = new RendererTabManager(() => {
|
||||
renderTabs(tm);
|
||||
renderContent(tm);
|
||||
});
|
||||
|
||||
function bindTabBarEvents(): void {
|
||||
document.getElementById('tabBar')!.addEventListener('click', (event) => {
|
||||
const target = event.target as HTMLElement;
|
||||
const action = target.dataset.action;
|
||||
const tabEl = target.closest('[data-tab-id]') as HTMLElement | null;
|
||||
const tabId = tabEl?.dataset.tabId;
|
||||
|
||||
if (action === 'add-tab') {
|
||||
tm.createTab();
|
||||
return;
|
||||
}
|
||||
if (action === 'close' && tabId) {
|
||||
event.stopPropagation();
|
||||
tm.closeTab(tabId);
|
||||
return;
|
||||
}
|
||||
if (action === 'rename' && tabId) {
|
||||
event.stopPropagation();
|
||||
renameTab(tm, tabId, tabEl!);
|
||||
return;
|
||||
}
|
||||
if (tabId) {
|
||||
tm.selectTab(tabId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function bindToolbarEvents(): void {
|
||||
document.getElementById('btnVk')!.addEventListener('click', () => loadURL(tm, VK_IM_URL));
|
||||
document.getElementById('btnTelemost')!.addEventListener('click', () => loadURL(tm, TELEMOST_URL));
|
||||
document.getElementById('btnHeadlessVK')!.addEventListener('click', () => tm.switchToHeadless(Platform.VK));
|
||||
document.getElementById('btnHeadlessTM')!.addEventListener('click', () => tm.switchToHeadless(Platform.Telemost));
|
||||
document.getElementById('modeSelect')!.addEventListener('change', (event) => {
|
||||
tm.setTunnelMode((event.target as HTMLSelectElement).value);
|
||||
});
|
||||
document.getElementById('btnSaveLogs')!.addEventListener('click', saveLogs);
|
||||
}
|
||||
|
||||
function bindActionBarEvents(): void {
|
||||
document.getElementById('btnVkCookies')!.addEventListener('click', () => {
|
||||
exportCookies('.vk.com', 'vk-cookies.json', 'No VK cookies found.\nPlease log into VK first.');
|
||||
});
|
||||
document.getElementById('btnYandexCookies')!.addEventListener('click', () => {
|
||||
exportCookies(
|
||||
'yandex',
|
||||
'cookies-yandex.json',
|
||||
'No Yandex cookies found.\nPlease log into Yandex (telemost.yandex.ru) first.',
|
||||
);
|
||||
});
|
||||
document.getElementById('btnSettings')!.addEventListener('click', openSettings);
|
||||
document.getElementById('tabBot')!.addEventListener('click', () => {
|
||||
if (!tm.botSettings.token || !tm.botSettings.groupId) {
|
||||
openSettings();
|
||||
return;
|
||||
}
|
||||
tm.toggleBot();
|
||||
});
|
||||
}
|
||||
|
||||
function bindSettingsEvents(): void {
|
||||
document.getElementById('btnSettingsCancel')!.addEventListener('click', closeSettings);
|
||||
document.getElementById('btnSettingsSave')!.addEventListener('click', () => {
|
||||
tm.botSettings.token = (document.getElementById('vkToken') as HTMLInputElement).value.trim();
|
||||
tm.botSettings.groupId = (document.getElementById('vkGroupId') as HTMLInputElement).value.trim();
|
||||
tm.botSettings.userId = (document.getElementById('vkUserId') as HTMLInputElement).value.trim();
|
||||
tm.saveBotSettings();
|
||||
closeSettings();
|
||||
});
|
||||
}
|
||||
|
||||
function bindErrorPopup(): void {
|
||||
document.getElementById('errorPopup')!.addEventListener('click', closeError);
|
||||
document.querySelector('#errorPopup .popup')!.addEventListener('click', (event) => event.stopPropagation());
|
||||
document.getElementById('btnErrorClose')!.addEventListener('click', closeError);
|
||||
}
|
||||
|
||||
function bindLogEvents(): void {
|
||||
document.getElementById('btnClearRelay')!.addEventListener('click', () => clearLog(LogPanel.Relay));
|
||||
document.getElementById('btnClearHook')!.addEventListener('click', () => clearLog(LogPanel.Hook));
|
||||
}
|
||||
|
||||
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;
|
||||
if (copyTarget) {
|
||||
const sourceEl = document.getElementById(copyTarget);
|
||||
if (sourceEl) copyToClipboard(sourceEl.textContent || '');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function openSettings(): void {
|
||||
document.getElementById('settingsPopup')!.classList.add('visible');
|
||||
(document.getElementById('vkToken') as HTMLInputElement).value = tm.botSettings.token;
|
||||
(document.getElementById('vkGroupId') as HTMLInputElement).value = tm.botSettings.groupId;
|
||||
(document.getElementById('vkUserId') as HTMLInputElement).value = tm.botSettings.userId;
|
||||
}
|
||||
|
||||
function closeSettings(): void {
|
||||
document.getElementById('settingsPopup')!.classList.remove('visible');
|
||||
}
|
||||
|
||||
function init(): void {
|
||||
bindTabBarEvents();
|
||||
bindToolbarEvents();
|
||||
bindActionBarEvents();
|
||||
bindSettingsEvents();
|
||||
bindErrorPopup();
|
||||
bindLogEvents();
|
||||
bindHeadlessEvents();
|
||||
|
||||
window.bridge.onRelayLog((tabId: string, msg: string) => {
|
||||
tm.appendRelayLog(tabId, msg);
|
||||
});
|
||||
|
||||
window.bridge.onBotError((msg: string) => {
|
||||
showError(msg);
|
||||
tm.botRunning = false;
|
||||
localStorage.setItem('botEnabled', 'false');
|
||||
renderBotButton(tm);
|
||||
});
|
||||
|
||||
window.bridge.onCreateBotTab((data: BotTabData) => {
|
||||
tm.createBotTab(data);
|
||||
(document.getElementById('modeSelect') as HTMLSelectElement).value = data.mode;
|
||||
window.bridge.setTunnelMode(data.tabId, data.mode);
|
||||
const url = data.platform === Platform.Telemost ? TELEMOST_URL : VK_IM_URL;
|
||||
loadURL(tm, url);
|
||||
});
|
||||
|
||||
window.bridge.onCloseBotTab((data: { tabId: string }) => {
|
||||
tm.closeTab(data.tabId);
|
||||
});
|
||||
|
||||
startHookLogPoller(tm);
|
||||
tm.autoStartBot();
|
||||
renderBotButton(tm);
|
||||
}
|
||||
|
||||
init();
|
||||
@@ -0,0 +1,213 @@
|
||||
import { RendererTab, BotTabData, BotSettings, TunnelMode, Platform, Bridge } from '../types';
|
||||
import { HeadlessLogMarker } from '../constants';
|
||||
|
||||
declare const window: Window & { bridge: Bridge };
|
||||
|
||||
export class RendererTabManager {
|
||||
tabs: Record<string, RendererTab> = {};
|
||||
activeTabId: string | null = null;
|
||||
private nextId = 1;
|
||||
botRunning = false;
|
||||
botSettings: BotSettings;
|
||||
private onRender: () => void;
|
||||
|
||||
constructor(onRender: () => void) {
|
||||
this.onRender = onRender;
|
||||
const saved = localStorage.getItem('botSettings');
|
||||
this.botSettings = saved
|
||||
? JSON.parse(saved)
|
||||
: { token: '', groupId: '', userId: '' };
|
||||
}
|
||||
|
||||
createTab(): string {
|
||||
const tabId = 'tab-' + this.nextId++;
|
||||
this.tabs[tabId] = {
|
||||
wv: null,
|
||||
url: '',
|
||||
mode: TunnelMode.DC,
|
||||
relayLogs: '',
|
||||
hookLogs: '',
|
||||
name: '',
|
||||
isBot: false,
|
||||
};
|
||||
window.bridge.startRelay(tabId);
|
||||
this.selectTab(tabId);
|
||||
return tabId;
|
||||
}
|
||||
|
||||
switchToHeadless(platform: Platform): void {
|
||||
if (!this.activeTabId) return;
|
||||
const tab = this.tabs[this.activeTabId];
|
||||
if (tab.wv) tab.wv.remove();
|
||||
const isTelemost = platform === Platform.Telemost;
|
||||
tab.wv = null;
|
||||
tab.url = '';
|
||||
tab.mode = isTelemost ? TunnelMode.HeadlessTelemost : TunnelMode.HeadlessVK;
|
||||
tab.name = isTelemost ? 'Headless TM' : 'Headless VK';
|
||||
tab.headless = true;
|
||||
tab.platform = platform;
|
||||
tab.callInfo = undefined;
|
||||
tab.headlessStatus = 'Starting...';
|
||||
tab.tunnelConnected = false;
|
||||
tab.relayLogs = '';
|
||||
tab.hookLogs = '';
|
||||
window.bridge.startHeadless(this.activeTabId, platform);
|
||||
this.onRender();
|
||||
}
|
||||
|
||||
createBotTab(data: BotTabData): void {
|
||||
if (!this.tabs[data.tabId]) {
|
||||
const botName = data.platform === Platform.Telemost ? 'Bot-Telemost' : 'Bot-VK';
|
||||
this.tabs[data.tabId] = {
|
||||
wv: null,
|
||||
url: '',
|
||||
mode: data.mode,
|
||||
relayLogs: '',
|
||||
hookLogs: '',
|
||||
name: botName,
|
||||
isBot: true,
|
||||
peerId: data.peerId,
|
||||
platform: data.platform,
|
||||
};
|
||||
}
|
||||
this.selectTab(data.tabId);
|
||||
}
|
||||
|
||||
closeTab(tabId: string): void {
|
||||
const tab = this.tabs[tabId];
|
||||
if (tab?.wv) tab.wv.remove();
|
||||
window.bridge.closeTab(tabId);
|
||||
delete this.tabs[tabId];
|
||||
if (this.activeTabId === tabId) {
|
||||
const ids = Object.keys(this.tabs);
|
||||
this.activeTabId = ids.length > 0 ? ids[ids.length - 1] : null;
|
||||
}
|
||||
this.onRender();
|
||||
}
|
||||
|
||||
selectTab(tabId: string): void {
|
||||
this.saveCurrentTabLogs();
|
||||
this.activeTabId = tabId;
|
||||
this.onRender();
|
||||
}
|
||||
|
||||
saveCurrentTabLogs(): void {
|
||||
if (this.activeTabId && this.tabs[this.activeTabId]) {
|
||||
const relayEl = document.getElementById('relayLog');
|
||||
const hookEl = document.getElementById('hookLog');
|
||||
if (relayEl) this.tabs[this.activeTabId].relayLogs = relayEl.textContent || '';
|
||||
if (hookEl) this.tabs[this.activeTabId].hookLogs = hookEl.textContent || '';
|
||||
}
|
||||
}
|
||||
|
||||
getActiveTab(): RendererTab | null {
|
||||
if (!this.activeTabId) return null;
|
||||
return this.tabs[this.activeTabId] || null;
|
||||
}
|
||||
|
||||
getTabLabel(tab: RendererTab): string {
|
||||
if (tab.name) return tab.name;
|
||||
if (tab.url) {
|
||||
if (tab.url.includes('vk.com')) return 'VK';
|
||||
if (tab.url.includes('telemost')) return 'Telemost';
|
||||
}
|
||||
return 'New';
|
||||
}
|
||||
|
||||
appendRelayLog(tabId: string, msg: string): void {
|
||||
const tab = this.tabs[tabId];
|
||||
if (!tab) return;
|
||||
tab.relayLogs += (tab.relayLogs ? '\n' : '') + msg;
|
||||
let rendered = false;
|
||||
if (tab.headless) rendered = this.parseHeadlessLog(tabId, msg);
|
||||
if (tabId === this.activeTabId && !rendered) {
|
||||
const el = document.getElementById('relayLog');
|
||||
if (el) {
|
||||
if (el.textContent!.length > 0) el.textContent += '\n';
|
||||
el.textContent += msg;
|
||||
el.scrollTop = el.scrollHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private parseHeadlessLog(tabId: string, msg: string): boolean {
|
||||
const tab = this.tabs[tabId];
|
||||
if (!tab) return false;
|
||||
const trimmed = msg.trim();
|
||||
let changed = false;
|
||||
|
||||
if (trimmed === HeadlessLogMarker.CALL_CREATED) {
|
||||
tab.callInfo = {};
|
||||
tab.headlessStatus = 'Call created';
|
||||
changed = true;
|
||||
}
|
||||
if (trimmed.includes(HeadlessLogMarker.JOIN_LINK)) {
|
||||
if (!tab.callInfo) tab.callInfo = {};
|
||||
tab.callInfo.joinLink = trimmed.split(HeadlessLogMarker.JOIN_LINK)[1].trim();
|
||||
changed = true;
|
||||
}
|
||||
if (trimmed.includes(HeadlessLogMarker.SHORT_LINK)) {
|
||||
if (!tab.callInfo) tab.callInfo = {};
|
||||
tab.callInfo.shortLink = trimmed.split(HeadlessLogMarker.SHORT_LINK)[1].trim();
|
||||
changed = true;
|
||||
}
|
||||
if (trimmed.includes(HeadlessLogMarker.TURN)) {
|
||||
if (!tab.callInfo) tab.callInfo = {};
|
||||
tab.callInfo.turn = trimmed.split(HeadlessLogMarker.TURN)[1].trim();
|
||||
changed = true;
|
||||
}
|
||||
if (trimmed.includes(HeadlessLogMarker.PROTOCOL)) {
|
||||
if (!tab.callInfo) tab.callInfo = {};
|
||||
tab.callInfo.protocol = trimmed.split(HeadlessLogMarker.PROTOCOL)[1].trim();
|
||||
changed = true;
|
||||
}
|
||||
if (trimmed.includes('[FATAL]')) {
|
||||
const fatalMessage = trimmed.split('[FATAL]')[1]?.trim() || 'fatal error';
|
||||
tab.headlessStatus = 'Disconnected: ' + fatalMessage;
|
||||
tab.tunnelConnected = false;
|
||||
changed = true;
|
||||
}
|
||||
if (changed && tabId === this.activeTabId) this.onRender();
|
||||
return changed;
|
||||
}
|
||||
|
||||
setTunnelMode(mode: string): void {
|
||||
if (!this.activeTabId) return;
|
||||
const tab = this.tabs[this.activeTabId];
|
||||
if (!tab) return;
|
||||
tab.mode = mode as TunnelMode;
|
||||
window.bridge.setTunnelMode(this.activeTabId, mode).then(() => {
|
||||
if (tab.wv) {
|
||||
tab.wv.executeJavaScript('window.__hookInstalled = false').catch(() => {});
|
||||
tab.wv.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
saveBotSettings(): void {
|
||||
localStorage.setItem('botSettings', JSON.stringify(this.botSettings));
|
||||
}
|
||||
|
||||
toggleBot(): void {
|
||||
if (!this.botSettings.token || !this.botSettings.groupId) return;
|
||||
this.botRunning = !this.botRunning;
|
||||
localStorage.setItem('botEnabled', this.botRunning ? 'true' : 'false');
|
||||
if (this.botRunning) {
|
||||
window.bridge.startBot(this.botSettings);
|
||||
} else {
|
||||
window.bridge.stopBot();
|
||||
}
|
||||
this.onRender();
|
||||
}
|
||||
|
||||
autoStartBot(): void {
|
||||
if (
|
||||
localStorage.getItem('botEnabled') === 'true' &&
|
||||
this.botSettings.token &&
|
||||
this.botSettings.groupId
|
||||
) {
|
||||
this.botRunning = true;
|
||||
window.bridge.startBot(this.botSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
import type { ChildProcess } from 'child_process';
|
||||
|
||||
export enum TunnelMode {
|
||||
DC = 'dc',
|
||||
PionVideo = 'pion-video',
|
||||
HeadlessVK = 'headless-vk',
|
||||
HeadlessTelemost = 'headless-telemost',
|
||||
}
|
||||
|
||||
export enum Platform {
|
||||
VK = 'vk',
|
||||
Telemost = 'telemost',
|
||||
}
|
||||
|
||||
export enum RelayMode {
|
||||
DCCreator = 'dc-creator',
|
||||
TelemostVideoCreator = 'telemost-video-creator',
|
||||
VKVideoCreator = 'vk-video-creator',
|
||||
}
|
||||
|
||||
export enum CallStatus {
|
||||
Active = 'active',
|
||||
Inactive = 'inactive',
|
||||
}
|
||||
|
||||
export enum BotCommand {
|
||||
VK = 'vk',
|
||||
TM = 'tm',
|
||||
List = 'list',
|
||||
Menu = 'menu',
|
||||
Close = 'close',
|
||||
}
|
||||
|
||||
export enum LogPanel {
|
||||
Relay = 'relay',
|
||||
Hook = 'hook',
|
||||
}
|
||||
|
||||
export interface PortPair {
|
||||
dc: number;
|
||||
pion: number;
|
||||
}
|
||||
|
||||
export interface TabState {
|
||||
relay: ChildProcess | null;
|
||||
tunnelMode: TunnelMode;
|
||||
platform: Platform;
|
||||
dcPort: number;
|
||||
pionPort: number;
|
||||
peerId?: number;
|
||||
isBot?: boolean;
|
||||
}
|
||||
|
||||
export interface BotSettings {
|
||||
token: string;
|
||||
groupId: string;
|
||||
userId: string;
|
||||
}
|
||||
|
||||
export interface TabConfig {
|
||||
mode: TunnelMode;
|
||||
peerId: number;
|
||||
platform: Platform;
|
||||
}
|
||||
|
||||
export interface TabListEntry {
|
||||
id: string;
|
||||
platform: Platform;
|
||||
mode: TunnelMode;
|
||||
isBot: boolean;
|
||||
callStatus: CallStatus;
|
||||
}
|
||||
|
||||
export interface CallInfo {
|
||||
joinLink?: string;
|
||||
shortLink?: string;
|
||||
turn?: string;
|
||||
protocol?: string;
|
||||
}
|
||||
|
||||
export interface Webview extends Electron.WebviewTag {
|
||||
getURL(): string;
|
||||
setAudioMuted(muted: boolean): void;
|
||||
executeJavaScript(code: string): Promise<any>;
|
||||
reload(): void;
|
||||
}
|
||||
|
||||
export interface RendererTab {
|
||||
wv: Webview | null;
|
||||
url: string;
|
||||
mode: TunnelMode;
|
||||
relayLogs: string;
|
||||
hookLogs: string;
|
||||
name: string;
|
||||
isBot: boolean;
|
||||
peerId?: number;
|
||||
platform?: Platform;
|
||||
headless?: boolean;
|
||||
headlessStatus?: string;
|
||||
callInfo?: CallInfo;
|
||||
tunnelConnected?: boolean;
|
||||
}
|
||||
|
||||
export interface BotTabData {
|
||||
tabId: string;
|
||||
mode: TunnelMode;
|
||||
peerId: number;
|
||||
platform: Platform;
|
||||
}
|
||||
|
||||
export interface RelayLogData {
|
||||
tabId: string;
|
||||
msg: string;
|
||||
}
|
||||
|
||||
export interface Bridge {
|
||||
onRelayLog(cb: (tabId: string, msg: string) => void): void;
|
||||
getHookCode(tabId: string, url: string): Promise<string>;
|
||||
setTunnelMode(tabId: string, mode: string): Promise<void>;
|
||||
startRelay(tabId: string): Promise<void>;
|
||||
closeTab(tabId: string): Promise<void>;
|
||||
startBot(settings: BotSettings): Promise<void>;
|
||||
stopBot(): Promise<void>;
|
||||
onCreateBotTab(cb: (data: BotTabData) => void): void;
|
||||
getCallCreatorCode(scriptFile: string): Promise<string>;
|
||||
onBotError(cb: (msg: string) => void): void;
|
||||
getCookies(domain: string): Promise<Electron.Cookie[]>;
|
||||
startHeadless(tabId: string, platform: string): Promise<void>;
|
||||
onCloseBotTab(cb: (data: { tabId: string }) => void): void;
|
||||
}
|
||||
@@ -0,0 +1,467 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, sans-serif;
|
||||
background: #1a1a1a;
|
||||
color: #e0e0e0;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.tab-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #222;
|
||||
border-bottom: 1px solid #333;
|
||||
height: 36px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.tab-bar-tabs {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
flex: 1;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.tab-bar-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
border-left: 1px solid #333;
|
||||
}
|
||||
|
||||
.tab {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 0 12px;
|
||||
height: 100%;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
border-right: 1px solid #333;
|
||||
white-space: nowrap;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.tab.active {
|
||||
background: #1a1a1a;
|
||||
color: #e0e0e0;
|
||||
}
|
||||
|
||||
.tab .close {
|
||||
font-size: 14px;
|
||||
opacity: 0.5;
|
||||
cursor: pointer;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.tab .close:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.tab .edit {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
opacity: 0;
|
||||
cursor: pointer;
|
||||
filter: invert(1) brightness(2);
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.tab:hover .edit {
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
.tab .edit:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.tab-add {
|
||||
padding: 0 12px;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.tab-add:hover {
|
||||
color: #e0e0e0;
|
||||
}
|
||||
|
||||
.tab-action-btn {
|
||||
padding: 0 12px;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.tab-action-btn:hover {
|
||||
color: #e0e0e0;
|
||||
}
|
||||
|
||||
.tab-action-btn.settings {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.tab-action-btn.bot {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.tab-action-btn.running {
|
||||
color: #dc3545;
|
||||
}
|
||||
|
||||
.tab-rename-input {
|
||||
width: 80px;
|
||||
padding: 0 4px;
|
||||
border: 1px solid #555;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
background: #111;
|
||||
color: #e0e0e0;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 6px 12px;
|
||||
background: #252525;
|
||||
border-bottom: 1px solid #333;
|
||||
height: 36px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.toolbar button {
|
||||
padding: 3px 12px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.btn-vk {
|
||||
background: #0077ff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-telemost {
|
||||
background: #fc3f1d;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-headless {
|
||||
background: #0077ff;
|
||||
color: white;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.btn-headless-tm {
|
||||
background: #fc3f1d;
|
||||
color: white;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.toolbar-spacer {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.toolbar-label {
|
||||
font-size: 11px;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.toolbar-select {
|
||||
padding: 2px 6px;
|
||||
border: 1px solid #555;
|
||||
border-radius: 6px;
|
||||
font-size: 11px;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
background: #333;
|
||||
color: #e0e0e0;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.toolbar-icon {
|
||||
cursor: pointer;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.toolbar-icon img {
|
||||
height: 16px;
|
||||
vertical-align: middle;
|
||||
filter: invert(1) brightness(2);
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.content webview {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.content webview.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.webview-full {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.welcome {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.welcome h1 {
|
||||
font-size: 22px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.welcome p {
|
||||
color: #888;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.headless-info {
|
||||
display: none;
|
||||
padding: 24px;
|
||||
color: #e0e0e0;
|
||||
font-family: monospace;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.headless-title {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.headless-status {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.headless-call-info {
|
||||
margin-top: 16px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.headless-row {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.headless-label {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.headless-link {
|
||||
color: #4fc3f7;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.headless-copy {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-left: 6px;
|
||||
cursor: pointer;
|
||||
vertical-align: middle;
|
||||
filter: invert(0.53);
|
||||
}
|
||||
|
||||
.headless-copy:hover {
|
||||
filter: invert(0.88);
|
||||
}
|
||||
|
||||
.headless-tunnel {
|
||||
margin-top: 16px;
|
||||
display: none;
|
||||
color: #4caf50;
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.logs {
|
||||
display: flex;
|
||||
gap: 0;
|
||||
border-top: 1px solid #333;
|
||||
height: 120px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.log-panel {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.log-panel:first-child {
|
||||
border-right: 1px solid #333;
|
||||
}
|
||||
|
||||
.log-title {
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
color: #888;
|
||||
padding: 3px 8px;
|
||||
background: #1e1e1e;
|
||||
border-bottom: 1px solid #333;
|
||||
}
|
||||
|
||||
.log-clear-btn {
|
||||
cursor: pointer;
|
||||
float: right;
|
||||
font-size: 13px;
|
||||
line-height: 13px;
|
||||
}
|
||||
|
||||
.log-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 3px 8px;
|
||||
font-family: monospace;
|
||||
font-size: 10px;
|
||||
background: #111;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.log-content.relay {
|
||||
color: #4fc3f7;
|
||||
}
|
||||
|
||||
.log-content.hook {
|
||||
color: #66bb6a;
|
||||
}
|
||||
|
||||
.popup-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
z-index: 1000;
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.popup-overlay.visible {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.popup {
|
||||
background: #2a2a2a;
|
||||
border-radius: 12px;
|
||||
padding: 24px;
|
||||
width: 400px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.popup h2 {
|
||||
margin: 0 0 20px;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #e0e0e0;
|
||||
}
|
||||
|
||||
.popup label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
font-size: 12px;
|
||||
color: #888;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.popup input {
|
||||
width: 100%;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #444;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
background: #1a1a1a;
|
||||
color: #e0e0e0;
|
||||
outline: none;
|
||||
margin-bottom: 16px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.popup input:focus {
|
||||
border-color: #0077ff;
|
||||
}
|
||||
|
||||
.popup-buttons {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.popup button {
|
||||
padding: 8px 16px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.btn-save {
|
||||
background: #0077ff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background: #444;
|
||||
color: #e0e0e0;
|
||||
}
|
||||
|
||||
.error-title {
|
||||
color: #dc3545;
|
||||
margin-bottom: 12px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.error-text {
|
||||
background: #111;
|
||||
padding: 10px;
|
||||
border-radius: 6px;
|
||||
font-size: 11px;
|
||||
color: #e0e0e0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
user-select: text;
|
||||
cursor: text;
|
||||
margin: 0;
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
class TelemostAutoclick {
|
||||
constructor() {
|
||||
this._interval = null;
|
||||
this._wvContents = null;
|
||||
}
|
||||
|
||||
attach(wvContents) {
|
||||
this.stop();
|
||||
this._wvContents = wvContents;
|
||||
this._interval = setInterval(() => this._scan(), 2000);
|
||||
wvContents.on('destroyed', () => this.stop());
|
||||
}
|
||||
|
||||
stop() {
|
||||
if (this._interval) {
|
||||
clearInterval(this._interval);
|
||||
this._interval = null;
|
||||
}
|
||||
this._wvContents = null;
|
||||
}
|
||||
|
||||
_scan() {
|
||||
try {
|
||||
this._wvContents.mainFrame.framesInSubtree.forEach((frame) => {
|
||||
frame.executeJavaScript(`
|
||||
(function() {
|
||||
var buttons = document.querySelectorAll('.Orb-Button, button, [role="button"], [role="link"]');
|
||||
var admitBtn = null;
|
||||
for (var i = 0; i < buttons.length; i++) {
|
||||
var txt = buttons[i].textContent.replace(/\\s+/g, ' ').trim();
|
||||
if (txt.indexOf('Впустить') !== -1) {
|
||||
admitBtn = buttons[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!admitBtn) return 'idle';
|
||||
|
||||
// Find guest's participant name
|
||||
var names = document.querySelectorAll('[class*="participantName"]');
|
||||
for (var j = 0; j < names.length; j++) {
|
||||
if (names[j].closest('[class*="selfView"]')) continue;
|
||||
var moreBtn = names[j].querySelector('[data-testid="show-moderation-popup"]');
|
||||
if (moreBtn) {
|
||||
moreBtn.click();
|
||||
return 'kick-open';
|
||||
}
|
||||
}
|
||||
|
||||
admitBtn.click();
|
||||
return 'admitted';
|
||||
})()
|
||||
`).then((r) => {
|
||||
if (r === 'kick-open') {
|
||||
setTimeout(() => this._clickRemove(frame), 500);
|
||||
} else if (r === 'admitted') {
|
||||
console.log('[auto-accept] guest admitted');
|
||||
}
|
||||
}).catch(function() {});
|
||||
});
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
_clickRemove(frame) {
|
||||
frame.executeJavaScript(`
|
||||
(function() {
|
||||
var el = document.querySelector('[title="Удалить со встречи"]');
|
||||
if (el) { el.click(); return true; }
|
||||
return false;
|
||||
})()
|
||||
`).then((r) => {
|
||||
if (r) setTimeout(() => this._confirmRemove(frame), 500);
|
||||
}).catch(function() {});
|
||||
}
|
||||
|
||||
_confirmRemove(frame) {
|
||||
frame.executeJavaScript(`
|
||||
(function() {
|
||||
var modal = document.querySelector('[data-testid="orb-modal2"]');
|
||||
if (!modal) return false;
|
||||
var btns = modal.querySelectorAll('button');
|
||||
for (var i = 0; i < btns.length; i++) {
|
||||
var txt = btns[i].textContent.replace(/\\s+/g, ' ').trim();
|
||||
if (txt === 'Удалить') {
|
||||
btns[i].click();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
})()
|
||||
`).then((r) => {
|
||||
if (r) console.log('[auto-accept] kicked previous participant');
|
||||
}).catch(function() {});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TelemostAutoclick;
|
||||
@@ -1,48 +0,0 @@
|
||||
(function() {
|
||||
if (window.__tmCallCreatorStarted) return;
|
||||
window.__tmCallCreatorStarted = true;
|
||||
|
||||
const start = () => {
|
||||
console.log("[BOT] Telemost: DOM ready...");
|
||||
|
||||
const waitAndClick = (fn) => {
|
||||
if (fn()) return;
|
||||
|
||||
const observer = new MutationObserver(() => {
|
||||
if (fn()) observer.disconnect();
|
||||
});
|
||||
|
||||
observer.observe(document.body, { childList: true, subtree: true });
|
||||
};
|
||||
|
||||
waitAndClick(() => {
|
||||
const btn = document.querySelector('[data-testid="create-call-button"]');
|
||||
|
||||
if (btn) {
|
||||
btn.click();
|
||||
console.log("[BOT] Telemost: creating call...");
|
||||
|
||||
const check = setInterval(() => {
|
||||
const url = location.href;
|
||||
|
||||
if (url.includes('/j/')) {
|
||||
console.log("[BOT] Telemost: call link:", url);
|
||||
window.__CALL_LINK__ = url;
|
||||
clearInterval(check);
|
||||
}
|
||||
}, 300);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", start);
|
||||
} else {
|
||||
start();
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "commonjs",
|
||||
"lib": ["ESNext", "DOM"],
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"declaration": false,
|
||||
"sourceMap": true
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["node_modules", "dist", "scripts"]
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
class VkAutoclick {
|
||||
constructor() {
|
||||
this._interval = null;
|
||||
this._wvContents = null;
|
||||
}
|
||||
|
||||
attach(wvContents) {
|
||||
this.stop();
|
||||
this._wvContents = wvContents;
|
||||
this._interval = setInterval(() => this._scan(), 2000);
|
||||
wvContents.on('destroyed', () => this.stop());
|
||||
}
|
||||
|
||||
stop() {
|
||||
if (this._interval) {
|
||||
clearInterval(this._interval);
|
||||
this._interval = null;
|
||||
}
|
||||
this._wvContents = null;
|
||||
}
|
||||
|
||||
_scan() {
|
||||
try {
|
||||
this._wvContents.mainFrame.framesInSubtree.forEach((frame) => {
|
||||
frame.executeJavaScript(`
|
||||
(function() {
|
||||
var admitBtn = document.querySelector('[data-testid="calls_waiting_hall_promote"]');
|
||||
if (!admitBtn) return 'idle';
|
||||
|
||||
// Kick current participant first if present (skip first = owner)
|
||||
var menuBtns = document.querySelectorAll('[data-testid="calls_participant_list_item_menu_button"]');
|
||||
if (menuBtns.length > 1) {
|
||||
menuBtns[menuBtns.length - 1].click();
|
||||
return 'kick-open';
|
||||
}
|
||||
|
||||
admitBtn.click();
|
||||
return 'admitted';
|
||||
})()
|
||||
`).then((r) => {
|
||||
if (r === 'kick-open') {
|
||||
setTimeout(() => this._clickKick(frame), 500);
|
||||
} else if (r === 'admitted') {
|
||||
console.log('[auto-accept] VK guest admitted');
|
||||
}
|
||||
}).catch(function() {});
|
||||
});
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
_clickKick(frame) {
|
||||
frame.executeJavaScript(`
|
||||
(function() {
|
||||
var btn = document.querySelector('[data-testid="calls_participant_actions_kick"]');
|
||||
if (btn) { btn.click(); return true; }
|
||||
return false;
|
||||
})()
|
||||
`).then((r) => {
|
||||
if (r) setTimeout(() => this._confirmKick(frame), 500);
|
||||
}).catch(function() {});
|
||||
}
|
||||
|
||||
_confirmKick(frame) {
|
||||
frame.executeJavaScript(`
|
||||
(function() {
|
||||
var btn = document.querySelector('[data-testid="calls_call_kick_submit"]');
|
||||
if (btn) { btn.click(); return true; }
|
||||
return false;
|
||||
})()
|
||||
`).then((r) => {
|
||||
if (r) console.log('[auto-accept] VK kicked previous participant');
|
||||
}).catch(function() {});
|
||||
}
|
||||
|
||||
kickDisconnected() {
|
||||
if (!this._wvContents) return;
|
||||
try {
|
||||
this._wvContents.mainFrame.framesInSubtree.forEach((frame) => {
|
||||
frame.executeJavaScript(`
|
||||
(function() {
|
||||
var menuBtns = document.querySelectorAll('[data-testid="calls_participant_list_item_menu_button"]');
|
||||
var menuBtn = menuBtns.length > 1 ? menuBtns[menuBtns.length - 1] : null;
|
||||
if (menuBtn) { menuBtn.click(); return true; }
|
||||
return false;
|
||||
})()
|
||||
`).then((r) => {
|
||||
if (r) setTimeout(() => this._clickKick(frame), 500);
|
||||
}).catch(function() {});
|
||||
});
|
||||
} catch(e) {}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = VkAutoclick;
|
||||
@@ -1,87 +0,0 @@
|
||||
(function() {
|
||||
if (window.__callCreatorStarted) return;
|
||||
window.__callCreatorStarted = true;
|
||||
|
||||
const start = () => {
|
||||
console.log("[BOT] VKCalls: DOM ready...");
|
||||
|
||||
const waitAndClick = (fn) => {
|
||||
if (fn()) return;
|
||||
|
||||
const observer = new MutationObserver(() => {
|
||||
if (fn()) observer.disconnect();
|
||||
});
|
||||
|
||||
observer.observe(document.body, { childList: true, subtree: true });
|
||||
};
|
||||
|
||||
waitAndClick(() => {
|
||||
const trigger = document.getElementById('call-menu-trigger');
|
||||
|
||||
if (trigger) {
|
||||
trigger.click();
|
||||
console.log("[BOT] VKCalls: opened call menu");
|
||||
|
||||
waitAndClick(() => {
|
||||
const el = [...document.querySelectorAll('span')]
|
||||
.find(e => e.textContent.includes('Создать звонок по'));
|
||||
|
||||
const btn = el?.closest('button, div');
|
||||
|
||||
if (btn) {
|
||||
btn.click();
|
||||
console.log("[BOT] VKCalls: created call");
|
||||
|
||||
const origFetch = window.fetch;
|
||||
window.fetch = async (...args) => {
|
||||
const res = await origFetch(...args);
|
||||
|
||||
if (window.__CALL_LINK_CAPTURED__) return res;
|
||||
|
||||
try {
|
||||
const clone = res.clone();
|
||||
const text = await clone.text();
|
||||
|
||||
if (text.includes("call_in_progress")) {
|
||||
const json = JSON.parse(text);
|
||||
const items = json?.response?.[1]?.items;
|
||||
|
||||
if (items) {
|
||||
for (const item of items) {
|
||||
const join = item?.call_in_progress?.join_link;
|
||||
if (join) {
|
||||
const link = "https://vk.com/call/join/" + join;
|
||||
|
||||
console.log("[BOT] VKCalls: call link:", link);
|
||||
window.__CALL_LINK__ = link;
|
||||
|
||||
window.__CALL_LINK_CAPTURED__ = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", start);
|
||||
} else {
|
||||
start();
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in new issue
Block a user