diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 3e6a9326..4910ec4a 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -391,6 +391,10 @@ "excludeStyleByUrlLabel": { "message": "Exclude the current URL" }, + "exportDeduplicate": { + "message": "Shift-click or Right-click will export a smaller file for UserCSS styles.\nSuch styles are importable only in Stylus 1.5.23 or newer.", + "description": "Tooltip for the button to export all styles in the 'manage' page" + }, "exportLabel": { "message": "Export", "description": "Label for the button to export a style ('edit' page) or all styles ('manage' page)" diff --git a/manage.html b/manage.html index c0eddb19..85b10f2e 100644 --- a/manage.html +++ b/manage.html @@ -323,7 +323,7 @@

- +
diff --git a/manage/import-export.js b/manage/import-export.js index 354283b9..f6ad56db 100644 --- a/manage/import-export.js +++ b/manage/import-export.js @@ -14,7 +14,10 @@ */// dom.js 'use strict'; -$('#file-all-styles').onclick = exportToFile; +Object.assign($('#file-all-styles'), { + onclick: exportToFile, + oncontextmenu: exportToFile, +}); $('#unfile-all-styles').onclick = () => importFromFile({fileTypeFilter: '.json'}); Object.assign(document.body, { @@ -325,13 +328,17 @@ async function importFromString(jsonString) { } } -async function exportToFile() { +/** @param {MouseEvent} e */ +async function exportToFile(e) { + e.preventDefault(); await require(['/js/storage-util']); + const shouldClean = e.shiftKey || e.button === 2; + const styles = await API.styles.getAll(); const data = [ Object.assign({ [prefs.STORAGE_KEY]: prefs.values, }, await chromeSync.getLZValues()), - ...(await API.styles.getAll()).map(cleanupStyle), + ...shouldClean ? styles.map(cleanupStyle) : styles, ]; const text = JSON.stringify(data, null, ' '); const type = 'application/json'; @@ -340,7 +347,7 @@ async function exportToFile() { download: generateFileName(), type, }).dispatchEvent(new MouseEvent('click')); - /** strip `sections`, `null` and empty objects */ + /** Stripping `sections`, `null` and empty objects */ function cleanupStyle(style) { const copy = {}; for (const [key, val] of Object.entries(style)) {