Load page without executing scripts, but allow scripts later

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

Load page without executing scripts, but allow scripts later

Postby wizofaus » Mon Aug 03, 2015 5:38 pm

I have need to take the DOM that has already been processed by a browser, i.e. all the scripts on it have already run, then do some post-processing on using CEF.
I can't let CEF re-execute the scripts in the HTML because doing so will create duplicate content in many cases.
The problem is that I need to be able to execute javascript to do the post-processing, and from what we've found so far, if you disable javascript execution before loading the content, you can't execute it later either.

Obviously one solution is to simply strip out all the scripts out of the HTML for the DOM, but the problem there is that some of the post-processing requires those scripts to be there - e.g. I need to be able to do things like enumerate script tags that load external resources.

If someone has a clue has to how this might be possible, or even as to where I might start looking in the CEF source as to how to add this functionality myself, I'd be eternally grateful!

Thanks

Dylan
wizofaus
Newbie
 
Posts: 8
Joined: Sun Aug 02, 2015 11:47 pm

Re: Load page without executing scripts, but allow scripts l

Postby wizofaus » Mon Aug 03, 2015 10:52 pm

BTW from what I can determine so far, I'd really need access to the underlying blink::WebFrame to be able to either change the "allowScripts" flag or to call some of the functions that allow executing scripts even when this flag is on.
But I don't believe that frame can be fetched, as it requires using blink::toFrameIfNotDetached( ) which doesn't seem to be exported from libcef.
Is it by design that libcef doesn't expose the blink/WebKit objects? Is the only option to modify libcef itself to add a function to allow, e.g., modifying the "allowScripts" flag after the WebFrame has been created?
Thanks again
Dylan

(PS I did mention this in an edit but not sure if it got moderated out, but the Chrome browser itself definitely supports executing javascript on a page from the dev tools console even when Javascript is disabled)

(PPS Would an option to disable executing scripts while the page is loading be to use a content security policy header?)
wizofaus
Newbie
 
Posts: 8
Joined: Sun Aug 02, 2015 11:47 pm

Re: Load page without executing scripts, but allow scripts l

Postby magreenblatt » Tue Aug 04, 2015 11:35 am

wizofaus wrote:Is it by design that libcef doesn't expose the blink/WebKit objects?

Yes.

wizofaus wrote:Is the only option to modify libcef itself to add a function to allow, e.g., modifying the "allowScripts" flag after the WebFrame has been created?

Could be.

wizofaus wrote:(PS I did mention this in an edit but not sure if it got moderated out, but the Chrome browser itself definitely supports executing javascript on a page from the dev tools console even when Javascript is disabled)

Did you test this in CEF?

wizofaus wrote:(PPS Would an option to disable executing scripts while the page is loading be to use a content security policy header?)

Not as far as I know.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 30 guests