DOM injection via WebKit Web Extension on WPE

  c++, webkit, webkit2-webextension, wpe

In WPE/WebKit, I want to programmatically inject a custom <script> element within the DOM of a loaded HTML resource, before the HTML is actually processed and loaded by the WebPage/WebFrame.

What is the easiest way to do that? Does the WebKit2 Web Extensions API provide support for such functionality, or do I have to patch the WebKit sources? Any pointers to respective documentation and/or example code are most welcome.

P.S. I already know WebKit2 Web Extensions API allows for injecting custom JavaScript code in response to the window-object-cleared signal, however, this does not fit my needs as the injected JavaScript executes code that depends on the presence of a valid DOM.

Source: Windows Questions C++

LEAVE A COMMENT