From cb23f89b6aaff4ff761f757a095d4b8432eaafe3 Mon Sep 17 00:00:00 2001 From: eight Date: Sun, 10 Sep 2017 22:04:43 +0800 Subject: [PATCH] Add: allow saveUsercss to build style --- background/storage.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/background/storage.js b/background/storage.js index 14b49673..674a705b 100644 --- a/background/storage.js +++ b/background/storage.js @@ -290,7 +290,14 @@ function filterUsercss(req) { function saveUsercss(style) { // This function use `saveStyle`, however the response is different. - return saveStyle(style) + return Promise.resolve() + .then(() => { + if (!style.name || !style.namespace) { + return Object.assign(usercss.buildMeta(style.source), style); + } + return style; + }) + .then(saveStyle) .then(result => ({ status: 'success', style: result