Run-time script injection


I’m trying to inject content in archived web pages in This worked well using the existing injectScripts, which is also used to inject ruffle, if the script is known at compile-time (script name bundled into sw.js).

How could I inject a script at run-time, e.g. when pressing a button in the interface? I have been unable to do so as of yet. If I try, its path is translated to inside the web archive, not to the injected script served from /static/proxy/.


Generally, we’re trying to avoid this type of custom injection as its hard to maintain / configure. I’m curious about the problem you’re trying to solve, and if there may be a more general solution to it?
If not, perhaps we can add something to make it more configurable.
The injectScripts was really added just to support Ruffle, and even that is a bit iffy now because ruffle is also needed at replay time.

Thank you for your reply! I’m experimenting with integrating Hypothesis into, to work with annotations on archived web pages.

Hypothesis’s sidebar would then be integrated in the UI. This needs some script injection into the archived web page (using cross-frame communication for its functionality), which in turns loads additional scripts and assets and interacts with a remote service.

It sounds like that this does not really fit well with
pywb may be a better fit, but I do like the interface - and the fact that one can work with single files as a full archive.
Hypothesis really needs something running within the frame to function. So if you have ideas how to make this work, I’d be interested to hear.