[wpe-webkit] Use WebKit-WPE Web Extensions to append custom <scipt> element to HTML DOM
Adrian Perez de Castro
aperez at igalia.com
Tue Jul 27 07:40:38 PDT 2021
On Tue, 27 Jul 2021 10:36:46 +0300 Michael Pantazoglou <michael.pantazoglou at oceanbluesoftware.co.uk> wrote:
> I have recently started working with the WebKit-WPE Web Extensions API to
> develop some additional functionality for the WPE browser. In particular, I
> need to 'inject' a custom <script> element to the HTML DOM *before* the
> latter is loaded/processed by the WebPage/WebFrame.
> As far as I have seen, the WebKit-WPE Extensions API allows for executing
> response to the window-object-cleared signal. However, those techniques do
> not serve my needs, because my custom <script> element executes JS code
> that needs the DOM document and document.documentElement to exist and be
> fully populated in advance.
The window-cleared-signal is intentionally triggered early during the
initialization of the JS context (hence the “cleared” in its name: it
will have a very minimal set of contents), before loaded content has had
any chance to touch it.
> So, I was wondering if the WebKit-WPE Extensions API provides any other
> signal that I could connect to and respond by altering the HTML DOM tree
> -or the raw network reply- before it is passed to the
> WebPage/WebFrame/HTMLDocumentParser. Has anybody else tried anything
> similar in the past? What is the best way to move forward besides patching
> WebKit itself?
The public API does not provide a way of replacing the raw network replies.
You can probably achieve your goal by using an injected script, see:
I hope this helps :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 195 bytes
Desc: not available
More information about the webkit-wpe