-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve scripts injection flow and logic #334
Comments
@ACTCD These are good idea, but I should note that |
@quoid We can choose any trigger early enough, I haven't evaluated them, but I believe we can surely find one or more available from below:
Worst case is we don't use |
@ACTCD All of the
We can not use |
@quoid Thank you so much for your investigation and clarification, it looks like we have the worst possible situation. For the above idea, we mainly need a trigger as early as possible to prepare and check for scripts updates in advance, as I said above, we can also just forgo the use of Another solution, maybe we could find an api in the native layer (swift) to monitor file changes in the scripts folder, actively push the updated files to the |
Could you elaborate more on how this will work?
|
@quoid This is still a very early idea and a lot of work needs to be done before it, I will update with more details in due course. |
When we complete the refactoring of #331, we could try to further optimize the script injection flow and speed up the scripts injection.
In
content.js
, we will accomplish scripts injection with just twobrowser.storage.local.get
asynchronous operations:This will do the fastest
document-start
scripts injection in content scripts, but cannot guarantee full priority over page scripts as there are still asynchronous operations.In
background.js
, which is responsible for updating the relevant information inbrowser.storage.local
, we can check and update the scripts corresponding to theurl
request as early as possible, we could use the following process:webNavigation.onBeforeNavigate
to get the requesturl
browser.storage.local.get
url
tobrowser.storage.local
and related indexes, and then update other scripts.Since the above process is optimized for injection speed, the background process may be completed later than the content scripts injection, which may cause the latest scripts code to not be applied when the page refresh/load of first time after the scripts is updated, but this should be acceptable, we can also provide an option switch to let the user decide whether to
inject first
orversion first
(For example, it is convenient for user script developers to debug).The above is just an idea, not tested and finalized, it may be rejected or not implemented for practical reasons.
The text was updated successfully, but these errors were encountered: