single export cookies button
This commit is contained in:
1 parent
b341370904
commit
beccc40522
12 files changed
+158
-132
No files matched your search
@@ -285,17 +285,12 @@ export function saveLogs(): void {
|
||||
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' });
|
||||
export function exportCookiesZip(): void {
|
||||
window.bridge.exportCookiesZip().then((bytes) => {
|
||||
const blob = new Blob([new Uint8Array(bytes)], { type: 'application/zip' });
|
||||
const anchor = document.createElement('a');
|
||||
anchor.href = URL.createObjectURL(blob);
|
||||
anchor.download = filename;
|
||||
anchor.download = 'cookies.zip';
|
||||
anchor.click();
|
||||
URL.revokeObjectURL(anchor.href);
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
closeError,
|
||||
clearLog,
|
||||
saveLogs,
|
||||
exportCookies,
|
||||
exportCookiesZip,
|
||||
copyToClipboard,
|
||||
renameTab,
|
||||
attachLoginWebview,
|
||||
@@ -66,30 +66,7 @@ function bindToolbarEvents(): void {
|
||||
}
|
||||
|
||||
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('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('btnExportCookies')!.addEventListener('click', exportCookiesZip);
|
||||
document.getElementById('btnSettings')!.addEventListener('click', openSettings);
|
||||
document.getElementById('tabBot')!.addEventListener('click', () => {
|
||||
if (!tm.botSettings.token || !tm.botSettings.groupId) {
|
||||
|
||||
Reference in new issue
Block a user