Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Execute "ExecuteJavaScript" before showing the page
Execute "ExecuteJavaScript" before showing the page
Hello, how to execute "ExecuteJavaScript" before showing the page, an example of how it works as an ad blocker, it hides blocks and then we see the page.
- salvadordf
- Posts: 4575
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Execute "ExecuteJavaScript" before showing the page
Hi,
If you try to call ExecuteJavascript before the TChromium initialization it won't work.
Ad blockers are usually a browser extension and right now there is limited support for them in CEF. You have a couple of demos in the /demos/Delphi_VCL/Extensions directory.
However, there are alternative ways to have an ad blocker like using the TChromium.OnBeforeResourceLoad event to block some resources depending on your criteria.
Read this document about the JavaScript integration in CEF :
https://bitbucket.org/chromiumembedded/ ... gration.md
The demos in the /demos/Delphi_VCL/JavaScript directory are Delphi translations of all the examples in that document.
Read the code comments in the demos, especially the comments in the JSExtension demo here :
https://github.com/salvadordf/CEF4Delph ... n.pas#L122
If you try to call ExecuteJavascript before the TChromium initialization it won't work.
Ad blockers are usually a browser extension and right now there is limited support for them in CEF. You have a couple of demos in the /demos/Delphi_VCL/Extensions directory.
However, there are alternative ways to have an ad blocker like using the TChromium.OnBeforeResourceLoad event to block some resources depending on your criteria.
Read this document about the JavaScript integration in CEF :
https://bitbucket.org/chromiumembedded/ ... gration.md
The demos in the /demos/Delphi_VCL/JavaScript directory are Delphi translations of all the examples in that document.
Read the code comments in the demos, especially the comments in the JSExtension demo here :
https://github.com/salvadordf/CEF4Delph ... n.pas#L122