diff --git a/background/style-manager.js b/background/style-manager.js index ce7e6149..6b53d883 100644 --- a/background/style-manager.js +++ b/background/style-manager.js @@ -79,7 +79,8 @@ const styleManager = (() => { addExclusion, removeExclusion, addInclusion, - removeInclusion + removeInclusion, + setMeta }); function handleColorScheme() { @@ -258,6 +259,18 @@ const styleManager = (() => { return removeIncludeExclude(id, rule, 'inclusions'); } + function setMeta(id, key, value) { + // FIXME: it is pretty danger to expose an API to modify *any* property on the data. + const oldData = styles.get(id).data; + if (oldData[key] === value) { + return; + } + const data = Object.assign({}, oldData); + data[key] = value; + return saveStyle(data) + .then(newData => handleSave(newData, 'styleSettings')); + } + function deleteStyle(id) { const style = styles.get(id); return db.exec('delete', id)