From e0124f66ba7f7c1bbd6162ecee381276e15ccb84 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 27 Apr 2017 01:09:52 +0300 Subject: [PATCH] code cosmetics --- backup/fileSaveLoad.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/backup/fileSaveLoad.js b/backup/fileSaveLoad.js index 9aa88603..203ff095 100644 --- a/backup/fileSaveLoad.js +++ b/backup/fileSaveLoad.js @@ -291,22 +291,20 @@ $('#file-all-styles').onclick = () => { return styleDigest ? Object.assign({styleDigest}, style) : style; }); const text = JSON.stringify(styles, null, '\t'); - const fileName = generateFileName(); - const url = 'data:text/plain;charset=utf-8,' + encodeURIComponent(text); + return url; // for long URLs; https://github.com/schomery/stylish-chrome/issues/13#issuecomment-284582600 - fetch(url) + }).then(fetch) .then(res => res.blob()) .then(blob => { const objectURL = URL.createObjectURL(blob); Object.assign(document.createElement('a'), { - download: fileName, + download: generateFileName(), href: objectURL, type: 'application/json', }).dispatchEvent(new MouseEvent('click')); setTimeout(() => URL.revokeObjectURL(objectURL)); }); - }); function generateFileName() { const today = new Date();