From 6a324eb1511c8969a112713f41c8defc2b178a00 Mon Sep 17 00:00:00 2001 From: eight04 Date: Sat, 4 Dec 2021 02:19:17 +0800 Subject: [PATCH 01/11] Add: style settings --- _locales/en/messages.json | 30 ++++++++++++++ background/style-manager.js | 7 ++++ edit.html | 52 +++++++++++++++++++++++- edit/base.js | 5 ++- edit/edit.css | 5 ++- edit/edit.js | 10 ++++- edit/sections-editor.js | 3 ++ edit/settings.css | 31 ++++++++++++++ edit/settings.js | 81 +++++++++++++++++++++++++++++++++++++ edit/source-editor.js | 3 ++ edit/tab.css | 28 +++++++++++++ edit/tab.js | 19 +++++++++ js/event-emitter.js | 37 +++++++++++++++++ 13 files changed, 305 insertions(+), 6 deletions(-) create mode 100644 edit/settings.css create mode 100644 edit/settings.js create mode 100644 edit/tab.css create mode 100644 edit/tab.js create mode 100644 js/event-emitter.js diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 66a885f880..004301a6cb 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,30 @@ "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": "User defined inclusion" + }, + "styleIncludeNewLabel": { + "message": "Add new inclusion rule" + }, + "styleExcludeLabel": { + "message": "User defined exclusion" + }, + "styleExcludeNewLabel": { + "message": "Add new exclusion rule" + }, + "stylePriorityLabel": { + "message": "Priority" + }, "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 c71a70ba03..a6c8b4ed83 100644 --- a/background/style-manager.js +++ b/background/style-manager.js @@ -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', codeIsUpdated: false}); + }, }; //#endregion diff --git a/edit.html b/edit.html index 23dbeb25ce..4cc9ce665d 100644 --- a/edit.html +++ b/edit.html @@ -17,6 +17,7 @@ + @@ -61,6 +62,7 @@ +