fix edge support
This commit is contained in:
parent
6ab4641812
commit
fa9bfa915d
|
@ -199,11 +199,11 @@ class BrowserApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
static downloadFile(win: Window, blobData: any, blobOptions: any, fileName: string) {
|
static downloadFile(win: Window, blobData: any, blobOptions: any, fileName: string) {
|
||||||
if (win.navigator.msSaveOrOpenBlob || BrowserApi.isSafariApi) {
|
if (BrowserApi.isSafariApi) {
|
||||||
const tab = BrowserApi.createNewTab(BrowserApi.getAssetUrl('downloader/index.html'));
|
const tab = BrowserApi.createNewTab(BrowserApi.getAssetUrl('downloader/index.html'));
|
||||||
const madeTab = BrowserApi.makeTabObject(tab);
|
const tabToSend = BrowserApi.makeTabObject(tab);
|
||||||
setTimeout(() => {
|
setTimeout(async () => {
|
||||||
BrowserApi.tabSendMessage(madeTab, {
|
BrowserApi.tabSendMessage(tabToSend, {
|
||||||
command: 'downloaderPageData',
|
command: 'downloaderPageData',
|
||||||
data: {
|
data: {
|
||||||
blobData: blobData,
|
blobData: blobData,
|
||||||
|
@ -214,12 +214,16 @@ class BrowserApi {
|
||||||
}, 1000);
|
}, 1000);
|
||||||
} else {
|
} else {
|
||||||
const blob = new Blob([blobData], blobOptions);
|
const blob = new Blob([blobData], blobOptions);
|
||||||
const a = win.document.createElement('a');
|
if (navigator.msSaveOrOpenBlob) {
|
||||||
a.href = win.URL.createObjectURL(blob);
|
navigator.msSaveBlob(blob, fileName);
|
||||||
a.download = fileName;
|
} else {
|
||||||
win.document.body.appendChild(a);
|
const a = win.document.createElement('a');
|
||||||
a.click();
|
a.href = win.URL.createObjectURL(blob);
|
||||||
win.document.body.removeChild(a);
|
a.download = fileName;
|
||||||
|
win.document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
win.document.body.removeChild(a);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
const isSafari = (typeof safari !== 'undefined') && navigator.userAgent.indexOf('Safari') !== -1 &&
|
const isSafari = (typeof safari !== 'undefined') && navigator.userAgent.indexOf('Safari') !== -1 &&
|
||||||
navigator.userAgent.indexOf('Chrome') === -1;
|
navigator.userAgent.indexOf('Chrome') === -1;
|
||||||
|
|
||||||
if (isSafari) {
|
if (!isSafari) {
|
||||||
safari.self.addEventListener('message', (msgEvent: any) => {
|
return;
|
||||||
doDownload(msgEvent.message);
|
|
||||||
}, false);
|
|
||||||
} else if (navigator.userAgent.indexOf(' Edge/') !== -1) {
|
|
||||||
chrome.runtime.onMessage.addListener((msg: any, sender: any, sendResponse: any) => {
|
|
||||||
doDownload(msg);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
safari.self.addEventListener('message', (msgEvent: any) => {
|
||||||
|
doDownload(msgEvent.message);
|
||||||
|
}, false);
|
||||||
|
|
||||||
function doDownload(msg: any) {
|
function doDownload(msg: any) {
|
||||||
if (msg.command === 'downloaderPageData' && msg.data) {
|
if (msg.command === 'downloaderPageData' && msg.data) {
|
||||||
const blob = new Blob([msg.data.blobData], msg.data.blobOptions);
|
const blob = new Blob([msg.data.blobData], msg.data.blobOptions);
|
||||||
|
|
|
@ -73,15 +73,15 @@ export class ExportController {
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
|
|
||||||
const foldersMap = new Map<string, any>();
|
const foldersMap = new Map<string, any>();
|
||||||
for (const f of decFolders) {
|
decFolders.forEach((f: any) => {
|
||||||
foldersMap.set(f.id, f);
|
foldersMap.set(f.id, f);
|
||||||
}
|
});
|
||||||
|
|
||||||
const exportCiphers = [];
|
const exportCiphers: any[] = [];
|
||||||
for (const c of decCiphers) {
|
decCiphers.forEach((c: any) => {
|
||||||
// only export logins and secure notes
|
// only export logins and secure notes
|
||||||
if (c.type !== CipherType.Login && c.type !== CipherType.SecureNote) {
|
if (c.type !== CipherType.Login && c.type !== CipherType.SecureNote) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cipher: any = {
|
const cipher: any = {
|
||||||
|
@ -99,7 +99,7 @@ export class ExportController {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (c.fields) {
|
if (c.fields) {
|
||||||
for (const f of c.fields) {
|
c.fields.forEach((f: any) => {
|
||||||
if (!cipher.fields) {
|
if (!cipher.fields) {
|
||||||
cipher.fields = '';
|
cipher.fields = '';
|
||||||
} else {
|
} else {
|
||||||
|
@ -107,7 +107,7 @@ export class ExportController {
|
||||||
}
|
}
|
||||||
|
|
||||||
cipher.fields += ((f.name || '') + ': ' + f.value);
|
cipher.fields += ((f.name || '') + ': ' + f.value);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (c.type) {
|
switch (c.type) {
|
||||||
|
@ -122,11 +122,11 @@ export class ExportController {
|
||||||
cipher.type = 'note';
|
cipher.type = 'note';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
exportCiphers.push(cipher);
|
exportCiphers.push(cipher);
|
||||||
}
|
});
|
||||||
|
|
||||||
const csv = papa.unparse(exportCiphers);
|
const csv = papa.unparse(exportCiphers);
|
||||||
return csv;
|
return csv;
|
||||||
|
|
Loading…
Reference in New Issue