Hack the crap out of Firefox for some useful error pages
I tried to get this to work in an extension, but it ain’t happening.
Update! It is now a working extension, mostly thanks to Nick, developer of InfoLister, and master of jedi XUL tricks. I’ll leave the original article as below for informational purposes.
How useful is the current error page for Firefox? I’ll answer for you: not very. You have the option of trying again, which will do nothing for you 99 times out of 100. It’s a glorified reload button, except smaller and located lower. Do you ever even hit the thing? I don’t- it’s basically as useless as the screen from Internet Explorer telling you to ask your system administrator what just happened. So, I decided to spruce it up a bit.
Most of the time, if I run across a page that should be there but isn’t, I’d like to run a few tests on it- a trace route, a whois search or maybe ping the place. Another thing I’d like to do is see if there’s an entry in the wayback machine. The last but usually most useful is looking at google’s cache of the page. I’ve implemented all of these on this hack, as well as a superfluous use of Eric Meyer’s CSS Complexspiral technique.
To pull this off on your own, you need a vague understanding of Firefox’s structure, a text editor, and an archival program, used to compress things into zip files. Oh yeah, you’ll need these files (right-click, save as):
I’m going to make a couple of assumptions, because it makes it easier on me, which is the imprtant thing. I’m assuming you’re going to use windows of some sort. Mac users can do this too, but I’m not sure exactly where all the files are you’ll need to wade through to do this. It may involve opening up some packages or something else that should be less confusing than it is. I’m also going to assume you know what Firefox is, since you’re going to be delving around under the hood of it.
Before you start, you will have to close Firefox. We’re going to be working on files that it uses in real-time. Read this article in its entirety before doing anything, then copy this post and paste it into your text editor.
Next, make backups of all of your files you might cry yourself to sleep over if you lost them. Cookies, bookmarks, extensions, etcetera. How you do this will not be discussed at the moment. Google usually knows all about things like that. Next, navigate to your Firefox directory in your Program Files folder.
Under your Mozilla Firefox folder, you should see a folder called chrome. Take note of the file toolkit.jar. This is what we’re going to be concerned with. Make a backup of this file in case something goes awry. Put it in a safe, warm place, like your desktop, or in some archival folder. Now, rename the original toolkit.jar to toolkit.zip. Windows will ask if you really want to do that- say yes. Now unzip that file in the current directory. This should create a folder named toolkit.
Navigate through your directory as such:
\toolkit\content\global
Rename the file netError.xhtml to netError.bak. Save those three files from eariler (the two .gif files and the .xhtml file) into this directory. Take a look through the .xhtml file with a text editor and you can see how the page is laid out, and modify anything you like. This isn’t necessary, but it can give you an idea of what is actually going on behind the scenes.
Once those files are saved, navigate back up the directory tree to the toolkit level. This is the only tricky step in the process. You want to re-zip everything back up: only from content on. You don’t want the actual toolkit folder in this archive. I have it so I can right-click on a folder in windows explorer and invoke my archival program, but yours may vary.
Important note: If you use WinRar, you must select “zip” as the archival type. A “rar” compression will corrupt the package and it will not work.
After the zipped file is created, rename it to toolkit.jar. Windows again will ask if you really want to do that- say yes. Now move it into the Mozilla Firefox/chrome folder, overwriting your original file.
That’s it- you’re done. Now you can have some marginally useful error pages, along with the benefit of looking underneath the hood of the Firefox engine. Don’t be afraid to poke around in there, you never know when you’ll come across something interesting.
Take note that if you update your browser, this file will disappear again, so make backups just as you would with anything else. I hope this has been handy for a couple of you out there. Feel free to comment on any other “hard” hacks that prove useful.
-->

August 20th, 2006 at 3:51 am
Hi there, this looks pretty neat! Like to implement it, but when done so it returns this error when the server is not found:
XML Parsing Error: not well-formed
Location: file:///e:/hack/netError.xhtml
Line Number 394, Column 4:ent/mozilla1.gif” />
—^
As you can see, here I just opened the xhtml-file directly from disk, but it returns the same error when implemented in chrome\toolkit.jar\content\global, be it with a different location.
Firefox 1.5.0.6 on Windows XP. Hope you can help or fix this, because this customized server not found page looks much more useful than the default!
August 20th, 2006 at 3:54 am
Oops, I see the error message didn’t come out like it was supposed to, let’s try this again:
XML Parsing Error: not well-formed
Location: file:///e:/hack/netError.xhtml
Line Number 394, Column 4:
ent/mozilla1.gif” />
—^
or maybe
XML Parsing Error: not well-formed
Location: file:///e:/hack/netError.xhtml
Line Number 394, Column 4:
ent/mozilla1.gif” />
—^
August 20th, 2006 at 8:29 am
Hello.
The same problem will happen over here. o.O
This is Firefox 1.5.0.6 on Win2k.
August 20th, 2006 at 9:25 am
Somehow I managed to include an extra snippet of nonsensical code in there. Try reloading your browsers and re-downloading the .xhtml file, and let me know what happens now.
August 20th, 2006 at 4:30 pm
Works better now, it displays the page! But somehow it passes the URL skipping the h… for example when clicking Ping it goes to http://www.dnsstuff.com/tools/ping.ch?ip=ttp://www.thisadressdoesntexits.com - it skips the h before the ttp://etc.
Also, what exactly is the deal with that Eric Meyer’s Complexspiral technique being used here? I mean, Firefox supports transparency in PNG’s and the CSS required to position the body background top-left and set a 1 pixel transparent PNG as the background for the content-division, so I don’t really get it.
August 20th, 2006 at 6:51 pm
That is indeed odd… I am not experiencing that behavior on my local copy. Here’s a screenshot of the ping option for a non-existent site dubbed “testing2006august.com”:
testing.png
Anyone else having problems with this?
As far as the Complexspiral comment, I just meant that I got the idea of having a picture look like half of it was looked through a transparent / semi-opaque window. There is no scrolling menu to speak of, but I always thought that it looked really slick how you could have two separate images and make it look like it was one that used transparent sections.
August 20th, 2006 at 10:01 pm
kaonashi is right… im getting the same problem.. even when using the file straight off this site…
observe
http://www.dnsstuff.com/tools/ping.ch?ip=ttp://roachfiend.com/netError.xhtm
August 21st, 2006 at 10:44 am
I haven’t tried this, but looking at your code I think you can simplify getDuffUrl(). Shouldn’t it just return document.location.href? The search()es you do there both return -1 in most cases. “duffUrl + 2″ then evaluates to 1, which would explain why the “h” is being cut off.
August 21st, 2006 at 5:56 pm
Thanks, Rory. I’ll try that out here in a second. I re-used code from an old netError page, and to be honest, that didn’t make any sense to me either. I just didn’t know what would work better.
Update: It works! You’ll have to clear your cache to see the change on the local page, or if you have downloaded it before. Please let me know how this works now for everyone. I guess it would have been a bit smoother post if it worked from the get-go, but that’s the advantage of having readers who are smarter than I am. Thanks, fellas.
August 22nd, 2006 at 12:46 pm
Great! Now, when I find some time, the customizing can begin :D
August 25th, 2006 at 2:25 pm
Is there a reason you can’t use override in chrome.manifest to package this as an extension?
http://developer.mozilla.org/en/docs/Chrome_Registration#override
August 27th, 2006 at 4:01 pm
Hey, Nick! There’s a perfectly obvious reason: I had no idea you could do that. I’ll have to dig a little to figure out how exactly to do that.
Overriding that opens up the doors considerably to what you can do with Firefox. Very interesting, thanks for the tip!
September 6th, 2006 at 12:31 pm
Thank you for the great work.
I tried to modify netError.xhtml to ease the pain of Internet censorship in Mainland China.
1. change google cache link
2. add Coralize link (you can access http://www.coralcdn.org/ to learn this project.)
download link:
http://www.oxyshare.com/get/14724407944ff05010e0f0/netError.zip.html
April 5th, 2008 at 9:00 am
[…] of junk. That’s where we come in.http://www.addict3d.org/news/328778/The Web&039s best free stuffroachfiend.com ? Hack the crap out of Firefox for some useful …Aug 20, 2006 … The same problem will happen over here. o.O. This is firefox 1.5.0.6 on Win2k. … […]