Firefox

jQuery in Firebug: How and why?

There are a number of folks out there who use the Firebug extension for FireFox so they can debug webpages. Firebug also includes a Javascript console so you can execute arbitrary Javascript code against the current page.

If you're a fan of the jQuery library, there's a way you can use that in Firebug (first documented here):

var j = document.createElement("script");
j.onload = jsCallback;
j.src = "http://code.jquery.com/jquery-latest.pack.js";
document.getElementsByTagName("head")[0].appendChild(j);

Note that line I have in bold? That fires a function called "jsCallback()" after jQuery is successfully loaded.

"Why a fancy callback?"

As I learned the hard way, if I were to just put Javascript code following the jQuery code, it might get executed before jQuery is successfully loaded, leading to errors. While I could just re-run the code (as jQuery would already be loaded), I was looking for a better solution to the problem, and this is what I came up with.

"So what can I do this callback?"

I'm glad you asked. One way using jQuery in Firebug comes in quite handy is if you want to dissect another web page. For example, let's say you want to run a Google search, and extract the URLs in the search results. Here's how to do it:

/**
* This is executed after jQuery is successfully loaded.
*/
function jsCallback() {

    var e = jQuery("a.l");

    var output = "";
    e.each(function() {
        output += jQuery(this).attr("href") + "\n";
    });

    alert(output);

}

var j = document.createElement("script");
j.onload = jsCallback;
j.src = "http://code.jquery.com/jquery-latest.pack.js";
document.getElementsByTagName("head")[0].appendChild(j);

"I could write $.get() calls to load Google's search results!"

Good luck with that. FireFox won't let you do that due to the same-origin policy.

"Well, how about if I get Google's search results in JSONP format?"

Um, good luck with that, too. You won't get very far without an HTTP referrer header, I'm afraid.

"So if I want to do this on an ad-hoc basis, I have to dissect the Google search results page?"

Yep, exactly.

Got any other tricks you find really useful to do with jQuery in Firebug? Let me know in the comments! 
 

0
No votes yet
Your rating: None

Delicious Booksmarks extension slow under Firefox 3 and Mac OS/X 10.4

Pretty much what the subject says. Running the latest version of the del.icio.us Firefox extension (2.0.72) in Firefox 3 on a G5 iMac with OS/X 10.4 ends up causing excessive CPU usage. And it seems that I am not the only one affected by this.

The main symptom of excessive CPU usage is starting up Activity Monitor and watching Firefox consume 10% of the CPU, even when it is sitting idle with a single empty tab open. Disabling the Delicious Firefox extension and restarting Firefox fixes the problem.

It appears that the folks who wrote the extension don't know what's going on either, so the only "fix" is to disable that extension. For the time being, I've added http://del.icio.us/post to my bookmarks so that I can still bookmark interesting sites.

[Edit: It has been pointed out to me that the buttons on this page will work nicely. Thanks Britta!

0
No votes yet
Your rating: None

Cool Firefox Extensions

I recently did some hunting for FireFox extensions, and found a few interesting ones that I'd like to share with y'all:

Cookie Manager Button
This lets you add a new button to your toolbar called "cookies". When clicked, it will take you straight to the interface for managing browser cookies. It's simple, but saves a few clicks from having to go through settings.
EM Menu
Adds a new item to the Tools menu called "Extensions". Click on that brings up a sub-menu which contains a list of your extensions. Clicking any of them brings up the options for that extension. Again, it saves clicks and the popping up of the extensions window.
Fission
If you've ever used Safari on a Mac, you'll like this one. It combines the progress bar and the address bar. So now when you load a page, the background of the address bar fills in with blue as the page loads.
Session Manager
This notes the current state of how many tabs are open, and what apge is loaded in each tab. You can manually save sessions and restore them later. Alternatively, you can even configure this extension to automatically save your session when you close Firefox and to restore that session when starting Firefox. Regular session backups can also be made, in the event of a crash.
0
No votes yet
Your rating: None

Funny FireFox Commercial

Seen on FireFoxFlicks.com:

0
No votes yet
Your rating: None
Syndicate content