-
Notifications
You must be signed in to change notification settings - Fork 369
Description
Revisiting this feature, I think we should deprecate it instead of implementing it.
The starting point for considering this issue has never been to maximize compatibility with third-party user scripts. We pay more attention to security, efficiency, ease of use, and maintainability.
User scripts are often a more lightweight snippet of code compared to the browser extension itself, rather than a complete replacement for the full extension interface.
In a browser extension, we can put any resource in the extension package and get it easily through the
runtime.getURL()API. But for user script resources, we cannot do this.Implementing similar APIs in user scripts requires very complex processes and at the expense of efficiency and maintainability, without providing significant advantages. Generally speaking:
- We need to parse those resources from user script metadata
- We need to download from the network and manage cache status sync to user scripts
- We need to convert it into a passable message (e.g. base64) and pass it from native to extension
- Then we need to pass it from the background script to the content script
- Finally we return it to the user script through the GM API
If it always needs to be converted to string (e.g. base64), why don't we embed it into user scripts from the beginning, but use complex separate resource management and delivery methods? It just adds complexity without saving any resources or improve performance.
And we now have a lot of excellent bundle tools that allow us to package complex projects into single user script files.
On the other hand. By leveraging native JS API
fetchorGM.xmlHttpRequest, we could already easily load any resource from the network and they better handle binary resources.Implementing an API represents our intention to maintain and encourage people to use it continuously, but at this point I can't see both, and in fact I'm more encouraging people to script in a simpler, native way.
Compared to many apps becoming increasingly large and bloated, I have been trying to do "subtract" in this extension from methods that are difficult to maintain and no longer recommended. And I delved into almost every detail to arrive at those decisions.
I am also a user and author of user scripts myself, so I wish to keep this extension a lightweight, simple, efficient, secure and maintainable user script manager, and I hope we could maintain some advantages and continually improve those still insufficient aspects.
Originally posted by @ACTCD in #224
For the same reason that we abandoned the implementation of @resource, I think we should also plan to deprecate @require to encourage people to use a more native and universal modern approach.
- Bundle them into end user scripts via packaging tools
- Use JS Native
Dynamic importAPIimport()
We hope to eventually strip these logic out of the core injection process, but in order to maintain compatibility with current scripts, we may provide internal or external alternatives.