x10Hosting Forums

Corporate Free Hosting for the Masses.


x10Hosting wishes you a great Year!

Register

Closed Thread
 
LinkBack Thread Tools Display Modes
x10Hosting Member

Join Date: Aug 2007
Posts: 12
Credits: 404
thephoenics is on a distinguished road
 
10-31-2007, 10:03 AM
Your First Firefox Extension

Firefox, the fun open-source browser that some ten percent of the web uses, has a secret.
No, not about:mozilla — that's old news. Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!
Yes, when you use Firefox's coolest features, like All-In-One Sidebar or MeasureIt, you're actually looking at glossy, beautiful extensions. Firefox's extensions add specific functions, things the creators never intended, neatly integrated into the browser. The range of possibilities is boundless — making an extension is more or less like building a new application to do whatever you want, within the confines of Firefox (or Mozilla. In this article whenever I say "Firefox," you can echo "or Mozilla" to yourself in your head if you're a Mozilla fan.)
Today let's take a look at how one goes about creating these magical extensions. The active ingredient is XUL, a markup language (the eXtensible [or "XML-Based"] User-interface Language, to be precise) that describes things like toolbars, menus, keyboard shortcuts. It's what Firefox uses internally, in fact, to handle its own UI (what the developer types call "chrome"). XUL will provide the interface. JavaScript handles the functionality.
thephoenics is offlineReport Post
Server Tech

GamingX's Avatar

Join Date: Aug 2007
Posts: 5,959
Credits: 18,901
GamingX has a brilliant future
Location: Bangalore, India

Send a message via AIM to GamingX
 
10-31-2007, 12:18 PM
Re: Your First Firefox Extension

My first extension was Foxy Tunes....Good little addon to play music on firefox.
__________________
Syed
Server Tech
GamingX is offlineReport Post
x10 Lieutenant

manzoor's Avatar

Join Date: Sep 2007
Posts: 430
Credits: 519
manzoor will become famous soon enough
Location: the Internet

 
10-31-2007, 12:37 PM
Re: Your First Firefox Extension

Mine was Youtube Downloader

Addon to download videos from Youtube.com, but now as there are many good softwares which let you download from Youtube.com I don't use it any more but I think my bro does, he downloads football videos from Youtube.com :D
__________________
If you find my posts helpful then please add my Reputation by click on this button at the top right of this post

/* No Comment */

while ( ! ( succeed = try () )); ------> Try Again

www.webhostingyes.com

manzoor is offlineReport Post
x10 Lieutenant

Flashgear's Avatar

Join Date: Jan 2006
Posts: 439
Credits: 1,752
Flashgear is on a distinguished road
Location: London, United Kingdom

Send a message via MSN to Flashgear
 
10-31-2007, 12:51 PM
Re: Your First Firefox Extension

Mine was Ad-block, which i installed recently.
__________________


Flashgear is offlineReport Post
x10Hosting Member

Join Date: Aug 2007
Posts: 12
Credits: 404
thephoenics is on a distinguished road
 
11-01-2007, 05:12 PM
Re: Your First Firefox Extension

XUUUUL

If you've ever worked with XML, you're hired! I mean, sorry — if you've ever worked with XML, then XUL will look familiar. Every XUL script starts with a namespace declaration, and has its content inside tags like <tooltip> and <progressmeter>. Firefox's XUL parser sits right next to its parsers for things like HTML and JavaScript, and they work along similar lines. If you need to know about nuts and bolts, you can check out XULPlanet and its exhaustive minute-by-minute coverage. Mozilla.org has a lot of info too.

While you're doing that, the rest of us will plunge right in. An extension consists of a number of components, all keenly synchronized. Here's a summary of extension anatomy. If you unzip an XPI file, which is the format extensions come in, and which is really just a specialized ZIP archive, you'll see a few standard pieces. Some extensions are large and multifaceted, but they all contain a few key elements. Most crucially, there's a file called install.rdf and a directory called chrome, which contains a JAR file. There may also be optional directories of stuff like components, defaults, and plugins. As it happens, that JAR is also a ZIP file under another name (sorry if you know all this already), and when we peer inside it in turn, we find (possibly among other things) the XUL file that does all the work.

So, to make our extension, we need to create each one of those files. Before you groan, though, install this extension handily designed for the purpose. The extension requires Firefox or Mozilla to run — if you're trying to make a Firefox extension but all you have installed is IE, maybe you should just print out this article and go read it in the park.
Edit:
Who's Got the Button?

The Extension Developer's Extension includes a handful of tools to make our job easier, including an interactive XUL editor, a fantastic place to play around with XUL. Let's restart our browsers and fire that one up right now. You should find it in the Tools menu under Extension Developer. The XUL editor window comes in two panes: at the top is the place where you put your XUL code, and watch it render at the bottom. It starts out with the namespace declaration, and a label tag that says:

<label value="Put your XUL here!"/>

Unlike HTML, you can't just have text hanging out untagged in XUL. Delete that label tag and replace it with:

<button label="Cute as a button"/>

And then marvel at your accomplishments:

button

Look at that! You made a button!

What else can we do? We can put our button on a toolbar, so it's not just hanging there in space, by surrounding it with toolbar tags:

<toolbar> <button label="Cute as a button"/> </toolbar>

We can put in a menu, too, if you like menus:

<menubar>
<menu label="Menu">
<menupopup>
<menuitem label="Grilled Cheese"/>
<menuitem label="Chocolate Milk"/>
<menuitem label="Fried Pickles"/>
</menupopup>
</menu>
</menubar>
Edit:
Adding Value

Looks nice, eh? Too bad it doesn't do anything. Let's give our UI some functionality. We do that with event handlers and a bit of JavaScript. The most useful, because it's the most versatile, event handler is called "command". It's triggered when the user activates an element, say, by clicking a button, or choosing a menu item. So if we add an oncommand attribute to our button, we can execute a script when it gets clicked:

<button label="Cute as a button" oncommand="alert('Ooh, that tickles!');"/>

Nifty, yeah? The handler can call functions from an external JavaScript file too, which is more useful. Just include a pointer to it up top, after the window definition:

<script type="application/x-javascript" src="chrome://myextension/content/cutescript.js"/>
Edit:
Now Wrap It To Go

Probably, if you want your extension to bring you fame and popularity, it'll have to do something more exciting than pop up a cute message, but that's your business. I'm just here to walk you through the basics. That file, cutescript.js, we'll wrap up in our XPI when the time comes. Heck, let's start putting stuff in place now. Create a working directory, call it MyCuteExtension or something, and give it a subdirectory called chrome, and another subdirectory called content. Open your favorite text editor and create cutescript.js in the content directory — it should just look like this:

function tickle(){
alert("Ooh, that tickles!");
}

Next, in the same directory, create the XUL file, cutexul.xul, which is basically what we did above:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="yourwindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://myextension/content/cutescript.js" />
<button label="Cute as a button" oncommand="tickle();"/>
<menubar>
<menu label="Menu">
<menupopup>
<menuitem label="Grilled Cheese"/>
<menuitem label="Chocolate Milk"/>
<menuitem label="Fried Pickles"/>
</menupopup>
</menu>
</menubar>
</window>

Then zip up those two files, call the resulting archive cute.jar, and put it in chrome. Meanwhile, leave the original, unzipped files in content. That's the musculature of our beast. What else do we need? A little infrastructure. In the content directory, create a file called contents.rdf. The RDF will explain what's what in the extension. It should look like this:

<?xml version="1.0"?>

<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">

<RDF:Seq about="urn:mozilla:package:root">
<RDF:li resource="urn:mozilla:package:mycuteextension"/>
</RDF:Seq>

<RDF:Description about="urn:mozilla:package:mycuteextension"
chrome:displayName="My Cute Extension"
chrome:author="Anonymous"
chrome:name="mycuteextension"
chrome:extension="true"/>

</RDF:RDF>
Edit:
At this point, if I haven't confused you, your directory structure should look like:

mycuteextension
| - chrome
- | - cute.jar
| - content
- | - contents.rdf
- | - cutexul.xul
- | - cutescript.js

The Extension Developer's Extension has some tools that help us with the next part, too, but the EDE is a work in progress so occasionally the procedure can be rocky (Here's the discussion forum.) Go to Tools -> Extension Developer -> Extension Builder. That will launch the Extension Builder tool. Tell it where your working directory is, then click "Edit install.rdf" and fill out the resulting form with your personal info and your extension's personal info. At the bottom, check Firefox and choose appropriate version numbers — 1.5 to 2.0 is a nice safe range (as of this writing), although for a real extension you'll want to be careful of compatibility issues. Click Save and Close. The Extension Builder should create an install.rdf file for you.

Next, click "Build extension," which will zip it all up into an XPI; and "Install extension," which will install your new Firefox extension! Whoooo! When you restart Firefox, you'll notice the button and menu bar that you created. Stay tuned for next month's tutorial on how to get rid of them.

If the auto-building process doesn't work, you can create your own install.rdf and zip it all up into your own XPI by hand.

Distribute that XPI file to your friends, or submit it to Mozilla's extension repository: anybody can double-click it to install your extension in their copy of Firefox.

Making extensions is a fairly complex business. I hope I've set you on the right road and not left out anything crucial. There are various approaches to the art of extension-crafting, various theories of directory structures, version changes, and so forth. This is a pretty comprehensive walkthrough, and this is an extremely comprehensive one.

Best of all, now that you know about the internal structure of an extension, you can hone your skills by taking apart other people's extensions to see how they work. Download an XPI (don't install it! Try right-clicking), unzip the XPI file and then the JAR file it contains, and use the Extension Developer's Extension to peek at both the XUL code that creates the interface, and the JavaScript that makes it run.

Last edited by thephoenics; 11-01-2007 at 05:12 PM. Reason: Automerged Doublepost
thephoenics is offlineReport Post
x10 Elder

QuwenQ's Avatar

Join Date: Sep 2007
Posts: 977
Credits: 532
QuwenQ will become famous soon enough
Location: Alamosa, CO

Send a message via AIM to QuwenQ
 
11-01-2007, 06:15 PM
Re: Your First Firefox Extension

Um, people, this isn't asking you for your first Add-on, it's telling you how to MAKE your own Add-on.
QuwenQ is offlineReport Post
x10Hosting Member

Join Date: Oct 2007
Posts: 3
Credits: 218
tehk7 is on a distinguished road
 
11-01-2007, 07:23 PM
Re: Your First Firefox Extension

I switched from Opera to firefox long ago, so naturally mine was the mouse gesture extension.
tehk7 is offlineReport Post
I'm so hood yeh!

Brandon's Avatar

Join Date: Jun 2006
Posts: 7,820
Credits: 7,383
Brandon is a glorious beacon of light
Location: The ghetto aka Tbury, Massachusetts

 
11-01-2007, 10:09 PM
Re: Your First Firefox Extension

I don't use extensions nor will I ever.
__________________
Thanks,
Brandon Retired Former x10Hosting Administrator
Brandon is offlineReport Post
Retired

Spartan Erik's Avatar

Join Date: Aug 2005
Posts: 3,361
Credits: 2,893
Spartan Erik is a glorious beacon of light
 
11-01-2007, 10:18 PM
Re: Your First Firefox Extension

I love how you copy pasted everything from this website:

http://www.webmonkey.com/06/25/index3a.html

Ought to mark it as spam for the sake of points but I'll let this be a warning.
Spartan Erik is offlineReport Post
Lord Of The Keys

Synkc's Avatar

Join Date: Jun 2007
Posts: 1,765
Credits: 11,388
Synkc will become famous soon enough
Location: Hervey Bay, Australia

 
11-02-2007, 03:03 AM
Re: Your First Firefox Extension

My first extension was Adblock Plus. Since then I've taken a liking to FasterFox.
__________________
E-mail: synkc[at]x10hosting[dot]com
Hirokima.com
Synkc is offlineReport Post
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft Firefox 2007 Professional DarkDragonLord Off Topic 22 09-14-2007 11:40 PM
Using an extension in Firefox, seems like this forum has leaking code! PSP-Heaven Off Topic 3 06-17-2006 04:13 PM
FireFox 1.5 Final is Out n4tec Scripts & 3rd Party Apps 10 12-02-2005 12:58 PM
Firefox: Using Firefox for Beginners pulse__xx Tutorials 9 11-26-2005 08:50 AM
'Extremely Critical' Bugs Found In Firefox stealth_thunder Scripts & 3rd Party Apps 14 05-15-2005 03:48 PM


All times are GMT -5. The time now is 07:41 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 RC7
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios