Skip to content

Commit

Permalink
Make it possible to export password metadata in Edge (requires compli…
Browse files Browse the repository at this point in the history
…cated steps but there doesn't seem to be another way)
  • Loading branch information
Wladimir Palant committed Oct 28, 2016
1 parent 9dfb9cd commit ee2367f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion chrome/data/platform.js
Expand Up @@ -70,7 +70,7 @@ exports.close = () => window.close();
// Work-around for https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/9550897/,
// inline all stylesheets.

if (window.navigator.userAgent.indexOf(" Edge/"))
if (window.navigator.userAgent.indexOf(" Edge/") >= 0)
{
window.addEventListener("DOMContentLoaded", () =>
{
Expand Down
1 change: 1 addition & 0 deletions data/allpasswords/allpasswords.html
Expand Up @@ -25,6 +25,7 @@
<div id="allpasswords-import-confirm" data-l10n-id="allpasswords-import-confirm"></div>
<div id="allpasswords-import-success" data-l10n-id="allpasswords-import-success"></div>
<div id="allpasswords-show-confirm" data-l10n-id="allpasswords-show-confirm"></div>
<div id="allpasswords-export-edge" data-l10n-id="allpasswords-export-edge"></div>
</div>

<!-- Cannot use <template> tag here, template contents are removed from document before l10n does its job -->
Expand Down
22 changes: 17 additions & 5 deletions data/allpasswords/main.js
Expand Up @@ -58,11 +58,23 @@ function exportData()
{
passwords.exportPasswordData().then(data =>
{
let link = $("exportData");
let blob = new Blob([JSON.stringify(data)], {type: "application/json"});
link.href = URL.createObjectURL(blob);
link.download = "passwords-backup-" + new Date().toISOString().replace(/T.*/, "") + ".json";
link.click();
if (window.navigator.userAgent.indexOf(" Edge/") >= 0)
{
// Edge won't let extensions download blobs (https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/9551771/)
// and it would ignore the file name anyway (https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/6594876/).
// data: URIs don't work either (https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/4282810/).
// Let the user copy the text manually, that's the only way.
if (confirm($("allpasswords-export-edge").textContent))
document.body.textContent = JSON.stringify(data);
}
else
{
let link = $("exportData");
let blob = new Blob([JSON.stringify(data)], {type: "application/json"});
link.href = URL.createObjectURL(blob);
link.download = "passwords-backup-" + new Date().toISOString().replace(/T.*/, "") + ".json";
link.click();
}
}).catch(showError);
}

Expand Down
1 change: 1 addition & 0 deletions locale/en-US.properties
Expand Up @@ -108,6 +108,7 @@ allpasswords-import-confirm = Importing passwords will only produce meaningful r
allpasswords-import-success = Passwords data has been imported.
allpasswords-show = Show passwords
allpasswords-show-confirm = This will display all your passwords on screen, please only proceed if nobody can watch over your shoulder. This action might take some time to complete.
allpasswords-export-edge = Bugs in Microsoft Edge currently prevent extensions from offering files for download. You will need to copy the text manually and paste it into a text editor such as Notepad.

# simple-prefs
autolock_title = Enable auto-lock
Expand Down

0 comments on commit ee2367f

Please sign in to comment.