diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 66a885f8..be2006e4 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -375,6 +375,12 @@ }, "description": "Title of the page for editing styles" }, + "editorCodeLabel": { + "message": "Code" + }, + "editorSettingLabel": { + "message": "Settings" + }, "enableStyleLabel": { "message": "Enable", "description": "Label for the button to enable a style" @@ -1634,6 +1640,21 @@ "message": "As a security precaution, the browser prohibits extensions from affecting its built-in pages (like chrome://version, the standard new tab page as of Chrome 61, about:addons, and so on) as well as other extensions' pages. Each browser also restricts access to its own extensions gallery (like Chrome Web Store or AMO).", "description": "Sub-note in the toolbar pop-up when on a URL Stylus can't affect" }, + "styleOriginLabel": { + "message": "Style origin" + }, + "styleUpdateUrlLabel": { + "message": "Update URL" + }, + "stylePreferSchemeLabel": { + "message": "Dark/Light mode" + }, + "styleIncludeLabel": { + "message": "Custom included sites" + }, + "styleExcludeLabel": { + "message": "Custom excluded sites" + }, "syncDropboxDeprecated": { "message": "Dropbox import/export is replaced by a more advanced style sync in the options page." }, diff --git a/background/style-manager.js b/background/style-manager.js index c71a70ba..b8243d03 100644 --- a/background/style-manager.js +++ b/background/style-manager.js @@ -283,7 +283,7 @@ const styleMan = (() => { async toggle(id, enabled) { if (ready.then) await ready; const style = Object.assign({}, id2style(id), {enabled}); - await saveStyle(style, {reason: 'toggle', codeIsUpdated: false}); + await saveStyle(style, {reason: 'toggle'}); return id; }, @@ -297,6 +297,13 @@ const styleMan = (() => { removeExclusion: removeIncludeExclude.bind(null, 'exclusions'), /** @returns {Promise} */ removeInclusion: removeIncludeExclude.bind(null, 'inclusions'), + + async config(id, prop, value) { + if (ready.then) await ready; + const style = Object.assign({}, id2style(id)); + style[prop] = value; + return saveStyle(style, {reason: 'config'}); + }, }; //#endregion @@ -375,7 +382,7 @@ const styleMan = (() => { throw new Error('The rule already exists'); } style[type] = list.concat([rule]); - return saveStyle(style, {reason: 'styleSettings'}); + return saveStyle(style, {reason: 'config'}); } async function removeIncludeExclude(type, id, rule) { @@ -386,10 +393,10 @@ const styleMan = (() => { return; } style[type] = list.filter(r => r !== rule); - return saveStyle(style, {reason: 'styleSettings'}); + return saveStyle(style, {reason: 'config'}); } - function broadcastStyleUpdated(style, reason, method = 'styleUpdated', codeIsUpdated = true) { + function broadcastStyleUpdated(style, reason, method = 'styleUpdated') { const {id} = style; const data = id2data(id); const excluded = new Set(); @@ -412,7 +419,6 @@ const styleMan = (() => { return msg.broadcast({ method, reason, - codeIsUpdated, style: { id, md5Url: style.md5Url, @@ -452,7 +458,7 @@ const styleMan = (() => { return handleSave(style, handlingOptions); } - function handleSave(style, {reason, codeIsUpdated, broadcast = true}) { + function handleSave(style, {reason, broadcast = true}) { const data = id2data(style.id); const method = data ? 'styleUpdated' : 'styleAdded'; if (!data) { @@ -460,7 +466,7 @@ const styleMan = (() => { } else { data.style = style; } - if (broadcast) broadcastStyleUpdated(style, reason, method, codeIsUpdated); + if (broadcast) broadcastStyleUpdated(style, reason, method); return style; } diff --git a/edit.html b/edit.html index 23dbeb25..567d4984 100644 --- a/edit.html +++ b/edit.html @@ -17,6 +17,7 @@ + @@ -61,6 +62,7 @@ + @@ -239,6 +241,8 @@ + + @@ -433,7 +437,53 @@ target="_blank"> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -478,5 +528,6 @@ +