Page 1 of 1

Attach script to webpage (inb4 'use Greasemonkey')

Posted: 2020-04-19, 14:03
by moonbat
I'm converting Pure URL from a bootstrap (not made by me) to an overlay extension. It cleans up garbage tracking parameters at 2 places - when URL requests are made, and also by cleaning up links on webpages. The first part uses an HTTP observer to fix outgoing links, the second part injects a static script using the Addon SDK's page-mod mechanism.

I was able to get the first part working by implementing an observer listener and calling the same function that processes regex on URLs. For the second part, there seems to be no direct equivalent in the overlay/XUL/XPCOM API.

I've been trying to use mozIJSSubScriptLoader detailed here in conjunction with attaching a script on page load or a listener on gBrowser, but no dice.

Is there another way to get a script to run on a webpage directly? This script in question is a large, complex one loaded from a chrome URL, so there's no fear of remote manipulation or anything like it, and the extension has worked flawlessly so far.