Another strategy would be to write a WebExtension that runs your script on the matching URLs and then you can start browser with a specific URL from command line.
I’m not aware of any tricks from pure command line that still work as most have been phased out in favour of more standard and cross-browser solutions.
Historically, one could pass javascript: urls to command line, but I think all the browsers have been phasing that out as being too much of a security risk.