Attach script to webpage (inb4 'use Greasemonkey')

Talk about code development, features, specific bugzilla bugs, enhancements, patches, and other highly technical things.
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific referenced Bugzilla bugs, mercurial, etc.

This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Most "bug reports" do not belong in this board and should initially be posted in Community Support or other relevant support boards.

Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
Post Reply
User avatar
Board Warrior
Board Warrior
Posts: 1616
Joined: 2015-12-09, 15:45

Attach script to webpage (inb4 'use Greasemonkey')

Post by moonbat » 2020-04-19, 14:03

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.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Linux Mint 20 Xfce x64 on HP i5 laptop with 12 GB RAM, always latest versions of PM & Basilisk unless specified.

Post Reply