12

I want to make a greasemonkey type script for firefox that runs before the scripts on the page. Greasemonkey scripts run after scripts on the page, so that won't work. The reason I need this is because I want to edit one of the scripts on the page. Specifically, I want to delete a script that forces the page to load inside a frame since having the page inside a frame breaks F5 (Pressing F5 makes the page jump back to the front page instead of reloading the current page). Also, I don't want to load the page through a proxy with AJAX and switching to chrome/opera is not an option either. I was thinking maybe the Jetpack add-on would work but it seems to only have the same event that greasemonkey uses, DOMContentLoaded. Any ideas?

Telanor
  • 4,419
  • 6
  • 29
  • 36
  • **IF** Opera was an option, than you could have simply renamed your `*.user.js` file to `*.js` and it would run before any content had even started loading. – c69 Dec 18 '11 at 00:47
  • I know, but I don't use opera as my browser. Since I've highly customized firefox, switching and still having everything the way I want it would probably be impossible. Installing and using another browser for just 1 site seems a little silly. – Telanor Dec 18 '11 at 03:33

1 Answers1

7

[edit 2013] Use the page-mod module of the Add-on SDK with contentScriptWhen = start.


older: Right, only newer Firefox builds (currently 3.7 nighlies, may later be added to 3.6.x) have support for running custom scripts before content-specified scripts. I wrote a prototype Jetpack-SDK module to take advantage of the new notification.

Is it a <script src> or an inline script? In the former case it can be blocked with a content policy (something adblock-like).

Nickolay
  • 31,095
  • 13
  • 107
  • 185