-
Notifications
You must be signed in to change notification settings - Fork 318
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
Find a way to inject scripts faster than we do it at the moment #1029
Comments
This feature is not reliable, but for some sites, it should inject scripts faster than inline scripts of the site itself.
Also in 2.10 JavaScript rules correctly work for iframes in Firefox |
The real example, when it is required: |
…odule Merge in EXTENSIONS/browser-extension from fix/AG-9455 to feature/AG-2737 Squashed commit of the following: commit 2d72a67 Author: Vladimir Zhelvis <[email protected]> Date: Mon Aug 9 18:52:40 2021 +0300 fix error message commit d166200 Merge: 7085785 71f9d66 Author: Vladimir Zhelvis <[email protected]> Date: Mon Aug 9 17:33:54 2021 +0300 Merge branch 'feature/AG-2737' into fix/AG-9455 commit 7085785 Author: Vladimir Zhelvis <[email protected]> Date: Mon Aug 9 17:32:52 2021 +0300 add tests commit e123448 Author: Vladimir Zhelvis <[email protected]> Date: Mon Aug 9 12:13:36 2021 +0300 handle request network error
Related issue: - uBlockOrigin/uBlock-issues#2350 As per AdGuard findings, it's possible (though unreliable) to try to inject scriptlets at webRequest.onResponseStarted time, which increases scriptlet injection reliability overall when injecting from multiple entry points. uBO was already injecting at webNavigation.onCommitted and main content script time, and adding webRequest.onResponseStarted as an entry point for scriptlet injection increases reliability for webpages which executes inline scripts at the top of the DOM. References: - AdguardTeam/AdguardBrowserExtension#1029 - https://github.com/AdguardTeam/AdguardBrowserExtension/blob/9ab85be5/Extension/src/background/webrequest.js#L620
We need to find a way to improve the current situation and reliably inject our scripts BEFORE the in-page scripts are executed.
There's no 100% reliable way (relevant feature request: https://bugs.chromium.org/p/chromium/issues/detail?id=471801), but we can try some hacks in order to achieve a better result than we have at the moment.
First of all, try figure what Tampermonkey does (as I recall they're using
onCommitted
just like we do, but I may be wrong).Here's what I suggest:
onBeforeRequest
listener to prepare scripts to be injected (and save it to some temp cache with -- use tabId and frameId pair as a cache key);onResponseStarted
(unreliable but fast) andonCommitted
(reliable but not fast enough) listeners to inject scripts;onCompleted
andonErrorOccurred
to clean up the cache;onCommitted
handler only;The text was updated successfully, but these errors were encountered: