Skip to content

Commit

Permalink
#120 Allow exporting settings without personal data
Browse files Browse the repository at this point in the history
Close #120
  • Loading branch information
Rafael committed Nov 4, 2017
1 parent c75b04c commit d7204c3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Extension/esgst.js
Original file line number Diff line number Diff line change
Expand Up @@ -27303,6 +27303,11 @@ function loadSMMenu(tab) {
Icons: [`fa-trash`],
Name: `esgst-heading-button`,
Title: `Delete data`
}, {
Check: true,
Icons: [`fa-gear`, `fa-arrow-circle-down`],
Name: `esgst-heading-button`,
Title: `Export settings (exports settings without personal data so you can easily share them with other users)`
}, {
Check: esgst.uf,
Icons: [`fa-user`, `fa-eye-slash`],
Expand Down Expand Up @@ -27472,6 +27477,7 @@ function loadSMMenu(tab) {
heading.firstElementChild.addEventListener(`click`, loadDataManagement.bind(null, false, `import`));
heading.firstElementChild.nextElementSibling.addEventListener(`click`, loadDataManagement.bind(null, false, `export`));
heading.firstElementChild.nextElementSibling.nextElementSibling.addEventListener(`click`, loadDataManagement.bind(null, false, `delete`));
heading.firstElementChild.nextElementSibling.nextElementSibling.nextElementSibling.addEventListener(`click`, exportSettings);
if (SMManageUserTags) {
SMManageUserTags.addEventListener(`click`, openManageUserTagsPopup);
}
Expand Down Expand Up @@ -31737,6 +31743,28 @@ function manageData(dm, dropbox, google, outlook, space, callback) {
dm.computerSpace.lastElementChild.textContent = convertBytes(totalGM);
}

function exportSettings() {
let data, url;
data = {
settings: JSON.parse(getValue(`settings`, `{}`))
};
delete data.settings.avatar;
delete data.settings.lastSync;
delete data.settings.steamApiKey;
delete data.settings.steamId;
delete data.settings.syncFrequency;
delete data.settings.username;
data = new Blob([JSON.stringify(data)]);
url = URL.createObjectURL(data);
file = document.createElement(`a`);
file.download = `esgst_data_${new Date().toISOString()}.json`;
file.href = url;
document.body.appendChild(file);
file.click();
file.remove();
URL.revokeObjectURL(url);
}

function checkDropboxComplete(data, dm, win, callback) {
if (!win || win.closed) {
if (dm.type === `export` || (data && esgst.settings.exportBackup)) {
Expand Down

0 comments on commit d7204c3

Please sign in to comment.