This commit is contained in:
hippoz 2022-09-27 16:23:50 +03:00
parent bd16ec07fe
commit 2655e12d90
No known key found for this signature in database
GPG key ID: 7C52899193467641

View file

@ -8,14 +8,14 @@ Plugins are pieces of Javascript that run on the web frontend. They get access t
Waffle also supports loading CSS using the `app:stylesheets` localstorage item (array of strings which contain css code).
Here's some general rules of thumb:
Here's some general info about plugins:
- There is no dedicated plugin API yet. Plugins simply get access to internal objects. This is because it is very difficult to create a good plugin API which covers most usecases. This also means plugins are liable to break with updates.
- The less "intrusive" the change, the less likely it is to break with an update: if your plugin uses `Proxy` on a bunch of internal functions and relies on weird behavior, it is very likely to break with an update.
- Never use `window.__waffle` in your plugin. It is designed for easy access into internal objects from the browser devtools. Plugins get the same access through the objects passed in `plugin.main`. The difference is that the plugin context can have certain differences in implementation and structure to ensure compatibility and safety.
## Loading
The client supports 2 ways of loading plugins:
The client supports 3 ways of loading plugins:
1. Automatic loading: the client iterates over all of the strings in the `app:javascript` localstorage array and executes them as Javascript.
2. Manual loading: done using a script that runs before the frontend's javascript, such as a userscript, a script injected in the HTML, or a WebExtension.
3. Pasting in the console: pasting the code of a plugin in the console. Useful for development, or when you don't have access to localstorage or userscripts.