-
Notifications
You must be signed in to change notification settings - Fork 104
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
packages: adblocker-electron{-preload}: make use of executeJavaScript
#4278
packages: adblocker-electron{-preload}: make use of executeJavaScript
#4278
Conversation
fd03028
to
efc1dca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we inject scriplets directly from get-cosmetic-filters-first
handler?
this will avoid unnecessary communication as what is happening here is:
-
- preload requests scriptlets by
get-cosmetic-filters-first
- preload requests scriptlets by
-
- background matches the scritlets and sends it back to preload
-
- preload sends scriptlets back to background to perform the injection with
adblocker-inject-script
- preload sends scriptlets back to background to perform the injection with
-
- background injects scripts in the main world
We can avoid steps 2 and 3, but injecting the scriptlets directly in the step 1.
22f5b22
to
987d06b
Compare
@seia-soto @chrmod I tried to streamline the implementation and fix the issues, please take another look at the patch. |
0a91253
to
03e4f4d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution. I found some headrooms to improve, but I really appreciate introducing the changes.
@seia-soto Thank you for the review! PTAL. I'll squash the commits once the review is through. |
82154cb
to
5c335de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks very great. No other comments from me. I requested a review from our team.
I found that we were missing tests from adblocker library from #4302 but this PR doesn't have any relationship with that. Therefore, I think it's fine to continue without additional rebasing. |
5c335de
to
7709fd8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for pushing this forward. It is clear that electron deserves improvements.
This review may take a bit more time as the entire team is catching up with electron changes and we want to be sure we can get most out of your efforts, so please bear with us :)
Was thinking, how about instead of requesting scriptlets from the preload
script, we push them directly based on did-navigate and did-frame-navigate which would make it closer to the way the Ghostery extension does the scritplet injection
With that approach, changes to the other cosmetic filters injection could be minimal.
Thank you for the review @chrmod! I've replied most of the comments, and I think the most important one to address is that I’d prefer to handle broader changes in other PRs since the electron package isn't fully functional right now. We rely on |
@chrmod PTAL, updated the branch! |
0939766
to
430c734
Compare
891c59e
to
198d3fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're almost there :)
Still need to ensure everything happens in the right moment.
Please let me know if you have any questions.
198d3fc
to
ece9443
Compare
@chrmod Pushed some changes that hopefully addresses the review. I'm losing the thread a bit, please let me know if the changes conform to what you suggested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need one more change around the async code.
Can you already confirm that this works with youtube.com ads?
ece9443
to
65c0cde
Compare
@chrmod Committed the suggestions. I can confirm that this works on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like one last thing is missing - I've made a code suggestion
565e649
to
1cf603a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now merge ready, we only have to fix the linter.
1181919
to
90eed89
Compare
Signed-off-by: nullptropy <nullptropy@tutanota.com>
90eed89
to
8ec3afe
Compare
Running CI. 👍 |
We would like to extend our sincere appreciation and congratulations to you for your valuable contribution to the adblocker library. We are pleased to merge this fix, which will benefit all users, and we are grateful for the time and effort you invested in addressing this issue. |
Many thanks @nullptropy ! |
Thanks for being patient with me and for all the hard work you guys put into this library, I really appreciate it! @seia-soto @chrmod |
wonderful work, thank you for your time and effort (ノ´ヮ´)ノ*: ・゚ |
Use
WebContents.executeJavaScript
for adblocker script injection.Preload script injection is subject to CSP, breaking functionality on some websites.
This change uses
executeJavaScript
API to bypass CSP:adblocker-inject-script
handler in main processFixes #4234