single export cookies button
This commit is contained in:
1 parent
b341370904
commit
beccc40522
12 files changed
+158
-132
No files matched your search
@@ -9,10 +9,7 @@
|
|||||||
<div class="tab-add" data-action="add-tab" title="New tab">+</div>
|
<div class="tab-add" data-action="add-tab" title="New tab">+</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-bar-actions">
|
<div class="tab-bar-actions">
|
||||||
<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="btnExportCookies" title="Export all cookies to cookies.zip for headless mode">Export 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" id="btnDionCookies" title="Export DION cookies to cookies-dion.json for headless mode">DION Cookies</div>
|
|
||||||
<div class="tab-action-btn" id="btnWBStreamCookies" title="Export WB Stream cookies to cookies-wbstream.json for headless mode">WB Cookies</div>
|
|
||||||
<div class="tab-action-btn settings" id="btnSettings" title="Settings">Settings</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 class="tab-action-btn bot" id="tabBot">Bot: Off</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export enum IPC {
|
|||||||
CLOSE_TAB = 'close-tab',
|
CLOSE_TAB = 'close-tab',
|
||||||
START_BOT = 'start-bot',
|
START_BOT = 'start-bot',
|
||||||
STOP_BOT = 'stop-bot',
|
STOP_BOT = 'stop-bot',
|
||||||
GET_COOKIES = 'get-cookies',
|
EXPORT_COOKIES_ZIP = 'export-cookies-zip',
|
||||||
RELAY_LOG = 'relay-log',
|
RELAY_LOG = 'relay-log',
|
||||||
CREATE_BOT_TAB = 'create-bot-tab',
|
CREATE_BOT_TAB = 'create-bot-tab',
|
||||||
CLOSE_BOT_TAB = 'close-bot-tab',
|
CLOSE_BOT_TAB = 'close-bot-tab',
|
||||||
|
|||||||
@@ -1,16 +1,9 @@
|
|||||||
import { ipcMain, session } from 'electron';
|
import { ipcMain } from 'electron';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as fs from 'fs/promises';
|
import * as fs from 'fs/promises';
|
||||||
import { TabManager } from './tab-manager';
|
import { TabManager } from './tab-manager';
|
||||||
import { BotManager } from '../bot/bot-manager';
|
import { BotManager } from '../bot/bot-manager';
|
||||||
import {
|
import { IPC } from '../constants';
|
||||||
IPC,
|
|
||||||
SESSION_PARTITION,
|
|
||||||
VK_COOKIE_DOMAINS,
|
|
||||||
YANDEX_COOKIE_DOMAINS,
|
|
||||||
DION_COOKIE_DOMAINS,
|
|
||||||
WBSTREAM_COOKIE_DOMAINS,
|
|
||||||
} from '../constants';
|
|
||||||
import { TunnelMode, Platform, BotSettings, HeadlessStartArgs } from '../types';
|
import { TunnelMode, Platform, BotSettings, HeadlessStartArgs } from '../types';
|
||||||
|
|
||||||
export function registerIpcHandlers(tabManager: TabManager): void {
|
export function registerIpcHandlers(tabManager: TabManager): void {
|
||||||
@@ -96,18 +89,7 @@ export function registerIpcHandlers(tabManager: TabManager): void {
|
|||||||
tabManager.sendBotCallLink(tabId, link);
|
tabManager.sendBotCallLink(tabId, link);
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle(IPC.GET_COOKIES, async (_e, domain: string) => {
|
ipcMain.handle(IPC.EXPORT_COOKIES_ZIP, async () => {
|
||||||
const ses = session.fromPartition(SESSION_PARTITION);
|
return tabManager.buildCookiesZip();
|
||||||
const all = await ses.cookies.get({});
|
|
||||||
let domains: string[];
|
|
||||||
if (domain === 'yandex') domains = YANDEX_COOKIE_DOMAINS;
|
|
||||||
else if (domain === 'dion') domains = DION_COOKIE_DOMAINS;
|
|
||||||
else if (domain === 'wbstream') domains = WBSTREAM_COOKIE_DOMAINS;
|
|
||||||
else 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;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -35,17 +35,8 @@ import {
|
|||||||
LOG_CAPTURE_SNIPPET,
|
LOG_CAPTURE_SNIPPET,
|
||||||
} from '../constants';
|
} from '../constants';
|
||||||
import { BotManager } from '../bot/bot-manager';
|
import { BotManager } from '../bot/bot-manager';
|
||||||
|
import { buildStoredZip } from './util/zip';
|
||||||
function resolveResourcePath(devRelative: string, packedName: string): string {
|
import { resolveResourcePath, binaryName } from './util/paths';
|
||||||
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 {
|
export class TabManager {
|
||||||
private tabs = new Map<string, TabState>();
|
private tabs = new Map<string, TabState>();
|
||||||
@@ -248,7 +239,6 @@ export class TabManager {
|
|||||||
cookieDomains: string[];
|
cookieDomains: string[];
|
||||||
platformName: string;
|
platformName: string;
|
||||||
binaryPath: string;
|
binaryPath: string;
|
||||||
getCookies: () => Promise<{ name: string; value: string }[]>;
|
|
||||||
} | null {
|
} | null {
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case Platform.Telemost:
|
case Platform.Telemost:
|
||||||
@@ -259,7 +249,6 @@ export class TabManager {
|
|||||||
cookieDomains: YANDEX_COOKIE_DOMAINS,
|
cookieDomains: YANDEX_COOKIE_DOMAINS,
|
||||||
platformName: 'Yandex',
|
platformName: 'Yandex',
|
||||||
binaryPath: this.headlessTelemostPath,
|
binaryPath: this.headlessTelemostPath,
|
||||||
getCookies: () => this.getYandexCookies(),
|
|
||||||
};
|
};
|
||||||
case Platform.Dion:
|
case Platform.Dion:
|
||||||
return {
|
return {
|
||||||
@@ -269,7 +258,6 @@ export class TabManager {
|
|||||||
cookieDomains: DION_COOKIE_DOMAINS,
|
cookieDomains: DION_COOKIE_DOMAINS,
|
||||||
platformName: 'DION',
|
platformName: 'DION',
|
||||||
binaryPath: this.headlessDionPath,
|
binaryPath: this.headlessDionPath,
|
||||||
getCookies: () => this.getDionCookies(),
|
|
||||||
};
|
};
|
||||||
case Platform.VK:
|
case Platform.VK:
|
||||||
return {
|
return {
|
||||||
@@ -279,7 +267,6 @@ export class TabManager {
|
|||||||
cookieDomains: VK_COOKIE_DOMAINS,
|
cookieDomains: VK_COOKIE_DOMAINS,
|
||||||
platformName: 'VK',
|
platformName: 'VK',
|
||||||
binaryPath: this.headlessVKPath,
|
binaryPath: this.headlessVKPath,
|
||||||
getCookies: () => this.getVKCookies(),
|
|
||||||
};
|
};
|
||||||
case Platform.WBStream:
|
case Platform.WBStream:
|
||||||
return {
|
return {
|
||||||
@@ -289,7 +276,6 @@ export class TabManager {
|
|||||||
cookieDomains: WBSTREAM_COOKIE_DOMAINS,
|
cookieDomains: WBSTREAM_COOKIE_DOMAINS,
|
||||||
platformName: 'WB Stream',
|
platformName: 'WB Stream',
|
||||||
binaryPath: this.headlessWBStreamPath,
|
binaryPath: this.headlessWBStreamPath,
|
||||||
getCookies: () => this.getWBStreamCookies(),
|
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
@@ -325,7 +311,7 @@ export class TabManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tab.tunnelMode = config.tunnelMode;
|
tab.tunnelMode = config.tunnelMode;
|
||||||
let cookies = await config.getCookies();
|
let cookies = await this.getCookiesForDomains(config.cookieDomains);
|
||||||
const refreshCookie = platform === Platform.WBStream ? 'wbx-refresh' : config.authCookie;
|
const refreshCookie = platform === Platform.WBStream ? 'wbx-refresh' : config.authCookie;
|
||||||
const needsLogin = !cookies.some((c) => c.name === refreshCookie);
|
const needsLogin = !cookies.some((c) => c.name === refreshCookie);
|
||||||
if (needsLogin) {
|
if (needsLogin) {
|
||||||
@@ -343,7 +329,7 @@ export class TabManager {
|
|||||||
this._mainWindow.webContents.send(IPC.LOGIN_DONE, { tabId });
|
this._mainWindow.webContents.send(IPC.LOGIN_DONE, { tabId });
|
||||||
}
|
}
|
||||||
this.sendLog(tabId, `${config.platformName} login captured.`);
|
this.sendLog(tabId, `${config.platformName} login captured.`);
|
||||||
cookies = await config.getCookies();
|
cookies = await this.getCookiesForDomains(config.cookieDomains);
|
||||||
}
|
}
|
||||||
this.sendLog(tabId, `${config.platformName} cookies (${cookies.length}): ${cookies.map((c) => c.name).join(', ')}`);
|
this.sendLog(tabId, `${config.platformName} cookies (${cookies.length}): ${cookies.map((c) => c.name).join(', ')}`);
|
||||||
this.killRelay(tabId, tab);
|
this.killRelay(tabId, tab);
|
||||||
@@ -460,27 +446,11 @@ export class TabManager {
|
|||||||
setTimeout(() => this.startRelay(tabId, tab), RELAY_RESTART_DELAY_MS);
|
setTimeout(() => this.startRelay(tabId, tab), RELAY_RESTART_DELAY_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getVKCookies(): Promise<{ name: string; value: string }[]> {
|
private async getCookiesForDomains(domains: string[]): Promise<{ name: string; value: string }[]> {
|
||||||
const ses = session.fromPartition(SESSION_PARTITION);
|
const ses = session.fromPartition(SESSION_PARTITION);
|
||||||
const all = await ses.cookies.get({});
|
const all = await ses.cookies.get({});
|
||||||
return all
|
return all
|
||||||
.filter((c) => c.domain != null && VK_COOKIE_DOMAINS.some((d) => c.domain!.includes(d)))
|
.filter((c) => c.domain != null && domains.some((d) => c.domain!.includes(d)))
|
||||||
.map((c) => ({ name: c.name, value: c.value }));
|
|
||||||
}
|
|
||||||
|
|
||||||
async getYandexCookies(): Promise<{ name: string; value: string }[]> {
|
|
||||||
const ses = session.fromPartition(SESSION_PARTITION);
|
|
||||||
const all = await ses.cookies.get({});
|
|
||||||
return all
|
|
||||||
.filter((c) => c.domain != null && YANDEX_COOKIE_DOMAINS.some((d) => c.domain!.includes(d)))
|
|
||||||
.map((c) => ({ name: c.name, value: c.value }));
|
|
||||||
}
|
|
||||||
|
|
||||||
async getDionCookies(): Promise<{ name: string; value: string }[]> {
|
|
||||||
const ses = session.fromPartition(SESSION_PARTITION);
|
|
||||||
const all = await ses.cookies.get({});
|
|
||||||
return all
|
|
||||||
.filter((c) => c.domain != null && DION_COOKIE_DOMAINS.some((d) => c.domain!.includes(d)))
|
|
||||||
.map((c) => ({ name: c.name, value: c.value }));
|
.map((c) => ({ name: c.name, value: c.value }));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,12 +483,19 @@ export class TabManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async getWBStreamCookies(): Promise<{ name: string; value: string }[]> {
|
async buildCookiesZip(): Promise<Buffer> {
|
||||||
const ses = session.fromPartition(SESSION_PARTITION);
|
const platforms: { filename: string; domains: string[] }[] = [
|
||||||
const all = await ses.cookies.get({});
|
{ filename: 'vk-cookies.json', domains: VK_COOKIE_DOMAINS },
|
||||||
return all
|
{ filename: 'cookies-yandex.json', domains: YANDEX_COOKIE_DOMAINS },
|
||||||
.filter((c) => c.domain != null && WBSTREAM_COOKIE_DOMAINS.some((d) => c.domain!.includes(d)))
|
{ filename: 'cookies-dion.json', domains: DION_COOKIE_DOMAINS },
|
||||||
.map((c) => ({ name: c.name, value: c.value }));
|
{ filename: 'cookies-wbstream.json', domains: WBSTREAM_COOKIE_DOMAINS },
|
||||||
|
];
|
||||||
|
const cookies = await Promise.all(platforms.map((p) => this.getCookiesForDomains(p.domains)));
|
||||||
|
const entries = platforms.map((p, i) => ({
|
||||||
|
name: p.filename,
|
||||||
|
data: Buffer.from(JSON.stringify(cookies[i], null, 2), 'utf8'),
|
||||||
|
}));
|
||||||
|
return buildStoredZip(entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setWBStreamDeviceId(id: string): Promise<void> {
|
async setWBStreamDeviceId(id: string): Promise<void> {
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { CallStatus, Platform } from '../../types';
|
||||||
|
|
||||||
|
export 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,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function extractTaggedCallLink(msg: string, platform: Platform): { tabId: string; link: string } | null {
|
||||||
|
const tag = platform === Platform.Telemost ? 'Telemost' : 'VKCalls';
|
||||||
|
const re = new RegExp('\\[BOT\\] ' + tag + '\\[([^\\]]*)\\]: call link:\\s*(.+)$');
|
||||||
|
const match = msg.match(re);
|
||||||
|
if (!match) return null;
|
||||||
|
return { tabId: match[1].trim(), link: match[2].trim() };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parseWBDeviceId(msg: string): string | null {
|
||||||
|
const match = msg.match(/\[WB_DEVICE_ID\]\s+(\S+)/);
|
||||||
|
return match ? match[1] : null;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { app } from 'electron';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
export function resolveResourcePath(devRelative: string, packedName: string): string {
|
||||||
|
if (app.isPackaged) {
|
||||||
|
return path.join(process.resourcesPath!, packedName);
|
||||||
|
}
|
||||||
|
return path.join(__dirname, '..', '..', '..', '..', devRelative);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function binaryName(base: string): string {
|
||||||
|
return process.platform === 'win32' ? base + '.exe' : base;
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
export interface ZipEntry {
|
||||||
|
name: string;
|
||||||
|
data: Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
const crc32Table = (() => {
|
||||||
|
const table = new Uint32Array(256);
|
||||||
|
for (let i = 0; i < 256; i++) {
|
||||||
|
let c = i;
|
||||||
|
for (let j = 0; j < 8; j++) c = (c & 1) ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
||||||
|
table[i] = c >>> 0;
|
||||||
|
}
|
||||||
|
return table;
|
||||||
|
})();
|
||||||
|
|
||||||
|
function crc32(buf: Buffer): number {
|
||||||
|
let c = 0xffffffff;
|
||||||
|
for (let i = 0; i < buf.length; i++) c = crc32Table[(c ^ buf[i]) & 0xff] ^ (c >>> 8);
|
||||||
|
return (c ^ 0xffffffff) >>> 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildStoredZip(entries: ZipEntry[]): Buffer {
|
||||||
|
const localChunks: Buffer[] = [];
|
||||||
|
const centralChunks: Buffer[] = [];
|
||||||
|
let offset = 0;
|
||||||
|
const dosTime = 0;
|
||||||
|
const dosDate = (1 << 5) | 1;
|
||||||
|
for (const entry of entries) {
|
||||||
|
const nameBytes = Buffer.from(entry.name, 'utf8');
|
||||||
|
const crc = crc32(entry.data);
|
||||||
|
const size = entry.data.length;
|
||||||
|
const lfh = Buffer.alloc(30);
|
||||||
|
lfh.writeUInt32LE(0x04034b50, 0);
|
||||||
|
lfh.writeUInt16LE(20, 4);
|
||||||
|
lfh.writeUInt16LE(0, 6);
|
||||||
|
lfh.writeUInt16LE(0, 8);
|
||||||
|
lfh.writeUInt16LE(dosTime, 10);
|
||||||
|
lfh.writeUInt16LE(dosDate, 12);
|
||||||
|
lfh.writeUInt32LE(crc, 14);
|
||||||
|
lfh.writeUInt32LE(size, 18);
|
||||||
|
lfh.writeUInt32LE(size, 22);
|
||||||
|
lfh.writeUInt16LE(nameBytes.length, 26);
|
||||||
|
lfh.writeUInt16LE(0, 28);
|
||||||
|
localChunks.push(lfh, nameBytes, entry.data);
|
||||||
|
const cdh = Buffer.alloc(46);
|
||||||
|
cdh.writeUInt32LE(0x02014b50, 0);
|
||||||
|
cdh.writeUInt16LE(20, 4);
|
||||||
|
cdh.writeUInt16LE(20, 6);
|
||||||
|
cdh.writeUInt16LE(0, 8);
|
||||||
|
cdh.writeUInt16LE(0, 10);
|
||||||
|
cdh.writeUInt16LE(dosTime, 12);
|
||||||
|
cdh.writeUInt16LE(dosDate, 14);
|
||||||
|
cdh.writeUInt32LE(crc, 16);
|
||||||
|
cdh.writeUInt32LE(size, 20);
|
||||||
|
cdh.writeUInt32LE(size, 24);
|
||||||
|
cdh.writeUInt16LE(nameBytes.length, 28);
|
||||||
|
cdh.writeUInt16LE(0, 30);
|
||||||
|
cdh.writeUInt16LE(0, 32);
|
||||||
|
cdh.writeUInt16LE(0, 34);
|
||||||
|
cdh.writeUInt16LE(0, 36);
|
||||||
|
cdh.writeUInt32LE(0, 38);
|
||||||
|
cdh.writeUInt32LE(offset, 42);
|
||||||
|
centralChunks.push(cdh, nameBytes);
|
||||||
|
offset += lfh.length + nameBytes.length + size;
|
||||||
|
}
|
||||||
|
const local = Buffer.concat(localChunks);
|
||||||
|
const central = Buffer.concat(centralChunks);
|
||||||
|
const eocd = Buffer.alloc(22);
|
||||||
|
eocd.writeUInt32LE(0x06054b50, 0);
|
||||||
|
eocd.writeUInt16LE(0, 4);
|
||||||
|
eocd.writeUInt16LE(0, 6);
|
||||||
|
eocd.writeUInt16LE(entries.length, 8);
|
||||||
|
eocd.writeUInt16LE(entries.length, 10);
|
||||||
|
eocd.writeUInt32LE(central.length, 12);
|
||||||
|
eocd.writeUInt32LE(local.length, 16);
|
||||||
|
eocd.writeUInt16LE(0, 20);
|
||||||
|
return Buffer.concat([local, central, eocd]);
|
||||||
|
}
|
||||||
@@ -4,7 +4,8 @@ import { TabManager } from './tab-manager';
|
|||||||
import { VkAutoclick } from '../autoclick/vk';
|
import { VkAutoclick } from '../autoclick/vk';
|
||||||
import { TelemostAutoclick } from '../autoclick/telemost';
|
import { TelemostAutoclick } from '../autoclick/telemost';
|
||||||
import { SESSION_PARTITION, USER_AGENT, WINDOW_WIDTH, WINDOW_HEIGHT } from '../constants';
|
import { SESSION_PARTITION, USER_AGENT, WINDOW_WIDTH, WINDOW_HEIGHT } from '../constants';
|
||||||
import { Platform, CallStatus } from '../types';
|
import { Platform } from '../types';
|
||||||
|
import { parseCallStatus, extractTaggedCallLink, parseWBDeviceId } from './util/log-tags';
|
||||||
|
|
||||||
function stripCSP(ses: Session): void {
|
function stripCSP(ses: Session): void {
|
||||||
ses.webRequest.onHeadersReceived((details, callback) => {
|
ses.webRequest.onHeadersReceived((details, callback) => {
|
||||||
@@ -17,28 +18,6 @@ function stripCSP(ses: Session): void {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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 extractTaggedCallLink(msg: string, platform: Platform): { tabId: string; link: string } | null {
|
|
||||||
const tag = platform === Platform.Telemost ? 'Telemost' : 'VKCalls';
|
|
||||||
const re = new RegExp('\\[BOT\\] ' + tag + '\\[([^\\]]*)\\]: call link:\\s*(.+)$');
|
|
||||||
const match = msg.match(re);
|
|
||||||
if (!match) return null;
|
|
||||||
return { tabId: match[1].trim(), link: match[2].trim() };
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createWindow(tabManager: TabManager): BrowserWindow {
|
export function createWindow(tabManager: TabManager): BrowserWindow {
|
||||||
const ses = session.fromPartition(SESSION_PARTITION);
|
const ses = session.fromPartition(SESSION_PARTITION);
|
||||||
stripCSP(ses);
|
stripCSP(ses);
|
||||||
@@ -130,9 +109,9 @@ export function createWindow(tabManager: TabManager): BrowserWindow {
|
|||||||
handleBotCallLink(tabManager, msg, Platform.VK);
|
handleBotCallLink(tabManager, msg, Platform.VK);
|
||||||
handleBotCallLink(tabManager, msg, Platform.Telemost);
|
handleBotCallLink(tabManager, msg, Platform.Telemost);
|
||||||
|
|
||||||
const deviceIdMatch = msg.match(/\[WB_DEVICE_ID\]\s+(\S+)/);
|
const deviceId = parseWBDeviceId(msg);
|
||||||
if (deviceIdMatch) {
|
if (deviceId) {
|
||||||
tabManager.setWBStreamDeviceId(deviceIdMatch[1]).catch(() => {});
|
tabManager.setWBStreamDeviceId(deviceId).catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
const callStatus = parseCallStatus(msg);
|
const callStatus = parseCallStatus(msg);
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ import { IPC } from '../constants';
|
|||||||
onBotError(cb: (msg: string) => void) {
|
onBotError(cb: (msg: string) => void) {
|
||||||
ipcRenderer.on(IPC.BOT_ERROR, (_e, msg) => cb(msg));
|
ipcRenderer.on(IPC.BOT_ERROR, (_e, msg) => cb(msg));
|
||||||
},
|
},
|
||||||
getCookies(domain: string) {
|
exportCookiesZip() {
|
||||||
return ipcRenderer.invoke(IPC.GET_COOKIES, domain);
|
return ipcRenderer.invoke(IPC.EXPORT_COOKIES_ZIP);
|
||||||
},
|
},
|
||||||
startHeadless(tabId: string, platform: string, args: any) {
|
startHeadless(tabId: string, platform: string, args: any) {
|
||||||
return ipcRenderer.invoke(IPC.START_HEADLESS, tabId, platform, args);
|
return ipcRenderer.invoke(IPC.START_HEADLESS, tabId, platform, args);
|
||||||
|
|||||||
@@ -285,17 +285,12 @@ export function saveLogs(): void {
|
|||||||
URL.revokeObjectURL(anchor.href);
|
URL.revokeObjectURL(anchor.href);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function exportCookies(domain: string, filename: string, errorMsg: string): void {
|
export function exportCookiesZip(): void {
|
||||||
window.bridge.getCookies(domain).then((cookies) => {
|
window.bridge.exportCookiesZip().then((bytes) => {
|
||||||
if (!cookies.length) {
|
const blob = new Blob([new Uint8Array(bytes)], { type: 'application/zip' });
|
||||||
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');
|
const anchor = document.createElement('a');
|
||||||
anchor.href = URL.createObjectURL(blob);
|
anchor.href = URL.createObjectURL(blob);
|
||||||
anchor.download = filename;
|
anchor.download = 'cookies.zip';
|
||||||
anchor.click();
|
anchor.click();
|
||||||
URL.revokeObjectURL(anchor.href);
|
URL.revokeObjectURL(anchor.href);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
closeError,
|
closeError,
|
||||||
clearLog,
|
clearLog,
|
||||||
saveLogs,
|
saveLogs,
|
||||||
exportCookies,
|
exportCookiesZip,
|
||||||
copyToClipboard,
|
copyToClipboard,
|
||||||
renameTab,
|
renameTab,
|
||||||
attachLoginWebview,
|
attachLoginWebview,
|
||||||
@@ -66,30 +66,7 @@ function bindToolbarEvents(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function bindActionBarEvents(): void {
|
function bindActionBarEvents(): void {
|
||||||
document.getElementById('btnVkCookies')!.addEventListener('click', () => {
|
document.getElementById('btnExportCookies')!.addEventListener('click', exportCookiesZip);
|
||||||
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('btnDionCookies')!.addEventListener('click', () => {
|
|
||||||
exportCookies(
|
|
||||||
'dion',
|
|
||||||
'cookies-dion.json',
|
|
||||||
'No DION cookies found.\nPlease log into DION (dion.vc) first.',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
document.getElementById('btnWBStreamCookies')!.addEventListener('click', () => {
|
|
||||||
exportCookies(
|
|
||||||
'wbstream',
|
|
||||||
'cookies-wbstream.json',
|
|
||||||
'No WB Stream cookies found.\nPlease log into stream.wb.ru first.',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
document.getElementById('btnSettings')!.addEventListener('click', openSettings);
|
document.getElementById('btnSettings')!.addEventListener('click', openSettings);
|
||||||
document.getElementById('tabBot')!.addEventListener('click', () => {
|
document.getElementById('tabBot')!.addEventListener('click', () => {
|
||||||
if (!tm.botSettings.token || !tm.botSettings.groupId) {
|
if (!tm.botSettings.token || !tm.botSettings.groupId) {
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ export interface Bridge {
|
|||||||
onCreateBotTab(cb: (data: BotTabData) => void): void;
|
onCreateBotTab(cb: (data: BotTabData) => void): void;
|
||||||
getCallCreatorCode(scriptFile: string): Promise<string>;
|
getCallCreatorCode(scriptFile: string): Promise<string>;
|
||||||
onBotError(cb: (msg: string) => void): void;
|
onBotError(cb: (msg: string) => void): void;
|
||||||
getCookies(domain: string): Promise<Electron.Cookie[]>;
|
exportCookiesZip(): Promise<Uint8Array>;
|
||||||
startHeadless(tabId: string, platform: string, args: HeadlessStartArgs): Promise<void>;
|
startHeadless(tabId: string, platform: string, args: HeadlessStartArgs): Promise<void>;
|
||||||
sendBotCallLink(tabId: string, link: string): Promise<void>;
|
sendBotCallLink(tabId: string, link: string): Promise<void>;
|
||||||
onCloseBotTab(cb: (data: { tabId: string }) => void): void;
|
onCloseBotTab(cb: (data: { tabId: string }) => void): void;
|
||||||
|
|||||||
Reference in new issue
Block a user