What I'm proposing is something I'm currently calling Megamarks. They combine the benefits of both Greasemonkey and bookmarklets and minimize some of the bigger problems. So, what's the difference?
Bookmarklets generally try to cram all of the code into a 255 character space (the space available for the URL in a bookmark). Within those confines, some amazing tools have been built. However, when you look at what the longer scripts for Greasemonkey do, there's so much room for growth. A megamark, on the other hand, doesn't try to actually do all of the work in the code. Rather, it uses the 255 character URL field in the bookmark as a bootstrap loader to pull in an arbitrary amount of code.
The first megamark I personally built was actually more of a bookmarklet, but it's my Light CSS link. It loads an external CSS file and applies it to the current page. However, what really smacked me in the face about the potential of the megamark concept is SlayerOffice's bookmarklet suite.
What you need to do is put your Javascript file up on an accessible server. That URL will go into the loader. Most of the stuff I've done with this technique has worked so far, but we're in a gray area, security-wise.
A quick test script to test the whole process:
window.alert("Megamark loaded.");
If you're looking for a bit more of a megamark, here's one that replaces the current document with a list of the URL's linked to in that page:
var $links = document.getElementsByTagName("A");
var $linklist;
for (var $loop = 0; $loop < $links.length; $loop++)
{
$linklist = $linklist + $links[$loop].href + "
";
}
document.write($linklist);
Here's the megamark loader:
javascript:s=document.body.appendChild
(document.createElement('script'));s.id='fs';
s.language='javascript';void(s.src='YOUR_JS_URL');
Take the megamark loader, replace YOUR_JS_URL with, well, your URL, and add a bookmark in Firefox with the loader, put back into one line as the URL. The bookmark will now inject your Javascript into the current document and run it. This is obviously just scratching the surface of what this technique can do. The AJAX methods could clearly extend these things to really scary levels. I'm working with the DOMMenu script to build an override right-click menu for working with links, RSS feeds (adding to Feed on Feeds), etc.
If you're looking for scripts to try using this technique (I've only tried a few so far), take a look at:
http://userscripts.org/
Note that these will NOT just run as is in most cases as they're designed to work within the Greasemonkey framework. Also note that these act a little funky with regard to the status bar and continuing to show some sort of loading after they're actually done. This will have to be looked at a bit more.
Also remember that this doesn't do anything until you run the megamark. Unlike the exploited Greasemonkey scripts, this is NOT running all the time and applying to sites you don't want it to.