Firefox Megamarks: The Next Generation of Bookmarklets

Originally published: 08/2005 by J Wynia

Firefox has a history of being the foundation layer for users and programmers taking control of the web. Bookmarklets, Extensions and Greasemonkey have all given more and more control over the sites you browse. However, most solutions still sit in one camp or the other. And, with the recent exploits of Greasemonkey, the value in having EVERY site loading all of your modifications (or deciding on a site-wide basis where to apply them) is being questioned. There are some solutions (like the wonderful Greasemonkey compiler that turns your script into a full-blown extension), but most of what I want to do with these doesn't justify a complete extension and I certainly don't want to have to install dozens of extensions when I can just have the CTRL+B bookmark tab have all of my modifications right there to apply on demand.

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 + "

Here's the megamark loader:


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:

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.


Steve on 8/31/2005
Funnily enough, I started using what you describe as a "megamark" (technique originally proposed by Liorean of AFAIK) because of MSIE's 508 byte limit on the length of a favorite...had nothing to do with Firefox, which to my knowledge doesnt suffer from any arbitrary byte limit. Megamark has a bit of a ring to it...I've been calling them "Hosted Favelets". This is an article I put together on the subject of authoring them (benefits, drawbacks, etc) a while back.
Revisiting Sites: Bookmarks are History-- The Glass is Too Big - J Wynia on 10/13/2005
[...] We’re seeing bits of this surface with Live Bookmarks (RSS Feeds as folders in your bookmarks) that come from the online bookmarking services. I’m finding myself using them (mostly Blinklist for my own use) for the whole “remember this content” problem and reserving bookmarks for bookmarklets, megamarks and things like admin panels to server administration. And even those are resisting tree structures being imposed on them. I’m constantly copying and moving them around because they really don’t fit together where they are. [...]
sbt on 11/9/2006
reminds me of user scripts in opera site prefs. i imagine you could tell opera to apply a remote file (on the lan or the net), not limited to specifying a script file on the same computer? (I've never tried this feature)
s on 11/9/2006
however script blockers (proxo etc) may pick up on the security "gray area" as you mention. need only to config those security features and ware to allow the remote script/let??
blog comments powered by Disqus
Or, browse the archives.
© 2003- 2015 J Wynia. Very Few Rights Reserved. This article is licensed under the terms of the Creative Commons Attribution License. Quoted content or content included from others is not subject to that license and defaults to normal copyright.