From ce988c280f5ca6dfc202d209e66d7cfce257c43b Mon Sep 17 00:00:00 2001 From: Bennett Date: Wed, 26 Feb 2020 12:12:02 +0100 Subject: Implement user.css and user.js (#401) * #83 Implement user.css and user.js * Fix button layout in settings * Fix user script not loading Co-authored-by: Amine --- README.md | 1 + src/actions/service.js | 3 +- .../settings/services/EditServiceForm.js | 65 +++++++---- src/containers/settings/EditServiceScreen.js | 26 ++--- src/i18n/locales/defaultMessages.json | 119 ++++++++++++++------- src/i18n/locales/en-US.json | 3 + .../settings/services/EditServiceForm.json | 119 ++++++++++++++------- src/stores/ServicesStore.js | 12 +-- src/styles/settings.scss | 10 +- src/webview/recipe.js | 33 ++++++ 10 files changed, 261 insertions(+), 130 deletions(-) diff --git a/README.md b/README.md index 5c4ca92dc..6a3a8ff54 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,7 @@ If you use an AUR Helper e.g. yay, simply install it via `yay -S ferdi`. - [x] Add Process Manager to find services using a lot of resources - [x] Add "npm run prepare-code" command for development to lint and beautify code - [x] Add button to open darkmode.css for a service +- [x] [Add `user.css` and `user.js` that allows users to inject custom code into services](https://github.com/getferdi/ferdi/wiki/Using-user.css-and-user.js) ([#83](https://github.com/getferdi/ferdi/issues/83)) - [x] Allow SVGs for service custom icon - [x] Switch to [`electron-spellchecker`](https://github.com/electron-userland/electron-spellchecker) to improve application size - [x] Improve "About Ferdi" screen to better display versions diff --git a/src/actions/service.js b/src/actions/service.js index d32bb80d3..f0c42e8aa 100644 --- a/src/actions/service.js +++ b/src/actions/service.js @@ -28,8 +28,9 @@ export default { serviceId: PropTypes.string.isRequired, redirect: PropTypes.string, }, - openDarkmodeCss: { + openRecipeFile: { recipe: PropTypes.string.isRequired, + file: PropTypes.string.isRequired, }, clearCache: { serviceId: PropTypes.string.isRequired, diff --git a/src/components/settings/services/EditServiceForm.js b/src/components/settings/services/EditServiceForm.js index 89c82c7f8..98051d78f 100644 --- a/src/components/settings/services/EditServiceForm.js +++ b/src/components/settings/services/EditServiceForm.js @@ -33,6 +33,18 @@ const messages = defineMessages({ id: 'settings.service.form.openDarkmodeCss', defaultMessage: '!!!Open darkmode.css', }, + openUserCss: { + id: 'settings.service.form.openUserCss', + defaultMessage: '!!!Open user.css', + }, + openUserJs: { + id: 'settings.service.form.openUserJs', + defaultMessage: '!!!Open user.js', + }, + recipeFileInfo: { + id: 'settings.service.form.recipeFileInfo', + defaultMessage: '!!!Your user files will be inserted into the webpage so you can customize services in any way you like. User files are only stored locally and are not transferred to other computers using the same account.', + }, availableServices: { id: 'settings.service.form.availableServices', defaultMessage: '!!!Available services', @@ -131,8 +143,7 @@ export default @observer class EditServiceForm extends Component { form: PropTypes.instanceOf(Form).isRequired, onSubmit: PropTypes.func.isRequired, onDelete: PropTypes.func.isRequired, - openDarkmodeCss: PropTypes.func.isRequired, - isOpeningDarkModeCss: PropTypes.bool.isRequired, + openRecipeFile: PropTypes.func.isRequired, isSaving: PropTypes.bool.isRequired, isDeleting: PropTypes.bool.isRequired, isProxyFeatureEnabled: PropTypes.bool.isRequired, @@ -199,8 +210,7 @@ export default @observer class EditServiceForm extends Component { isSaving, isDeleting, onDelete, - openDarkmodeCss, - isOpeningDarkModeCss, + openRecipeFile, isProxyFeatureEnabled, isServiceProxyIncludedInCurrentPlan, isSpellcheckerIncludedInCurrentPlan, @@ -226,23 +236,6 @@ export default @observer class EditServiceForm extends Component { /> ); - const openDarkmodeCssButton = isOpeningDarkModeCss ? ( -