Announcing "Slashdot Redirect" Firefox extension..

Talk about add-ons and extension development.
Post Reply
phallstrom
Posts: 6
Joined: August 6th, 2003, 1:05 pm

Announcing "Slashdot Redirect" Firefox extension..

Post by phallstrom »

Hi all -

I've written my first extension for firefox and both wanted to get it out there and get some help.

In a nutshell it redirects you from "xxx.slashdot.org/...." to "slashdot.org/..." where "xxx" is any of the sub-sites of slashdot. It does this because I can't stand their themes.

http://www.pjkh.com/extensions/slashdotredirect/

Here's my questions:

- This extension adds a listener to the onload event so it has to load the entire page before it can swap it out. There's got to be a way to do it earlier, no?

- It doesn't work when you middle click on a link to open it in a background tab. Obviously, I'm not "hooking" in at the right place, but this being my first extension, I'm not entirely sure where to link in to.

Any pointers to source/examples/reference are greatly appreciated!

-philip
kagaku
Posts: 98
Joined: December 8th, 2002, 10:11 pm
Location: Burbank, IL USA
Contact:

Post by kagaku »

THANK YOU.

Just fix those two bugs and I'll be set for life.
kagaku
We're all just noise on the wires..
phallstrom
Posts: 6
Joined: August 6th, 2003, 1:05 pm

Post by phallstrom »

Your welcome! I found that over the last couple of months I would constantly edit the URL to remove the "it" and "games". The others aren't too bad, but those two are awful.

If you have any idea how I can tie into that middle click let me know and I'll add it.

I suspect, it's not tying into the middle click though, my guess is that somewhere there is an "open this url now" function that I want to hook into and modify it there. That would change it before you load it and cover any possible method of opening the url (bookmark, email, pasted, whatever)... I just don't know where to find it yet :(

But it helps a little bit.
Mook
Posts: 1752
Joined: November 7th, 2002, 9:35 pm

Post by Mook »

For the second thing, SR_onPageLoad checks against _content; _content is foreground tab contents. Hence you're skipping the check if the content was not loaded in the foreground tab in the outermost frame.

Also, it looks like it will catch URLs like http://example.com/oldstuff/foo.slashdot.org/article.pl (and redirect that to the real /.).

As for the first - not sure, you may want to see what the LiveHTTPHeaders people are doing and see if it helps - I don't actually know if you can rewrite stuff based on what they're using though.

(Stupid Proximitron - won't do the header redirect for me after the reinstall for some reason)

P.S. Your server appears to be serving the XUL file as application/vnd.mozilla.xul+xml for your source view :) So the browser tries to load it instead...
poot.
phallstrom
Posts: 6
Joined: August 6th, 2003, 1:05 pm

Post by phallstrom »

Ah... you learn something new everyday. Saw a lot of _content in examples :-)

And your right about matching against longer urls. I should really add a check against 'host' I suppose.

thanks for the tip on livehttpheaders I'll look at that when I get the chance.

-philip
Post Reply