Extentsions FAQ

Return to mozilla-dev-extensions


FAQ

Friday, September 22 - 29, 2006

(↑ top)

How to write an XPCOM component in C++ that can communicate to a COM component?
Write an XPCOM component in C++ - it will talk to the COM component and will be accessible to JS code via XPConnect.
How to customizes toolbar button to coexist in a toolbar palette and status bar?
Option #3
Install Status Buttons 1.0
<https://addons.mozilla.org/firefox/1272/>
"Lets you put toolbar buttons at either end of the status-bar. Just drag them there from the toolbar customisation window, like you would when adding buttons to the toolbars."
Option #4
Install Toolbar Control
<http://webdesigns.ms11.net/chromeditp.html>
How to creating an extension that can replace HTML code on a specific page that does not use Greasemonkey?
var newNode = document.createElement(" ... html content here ... ");
var replaceMe = document.getElementById("replaceMe");
replaceMe.parentNode.replaceChild(newNode, replaceMe);
Is it possible to place an image in the window that can be moved to anywhere in the window, and always remain on top of everything else?(similiar to using position:absolute and-index:100000 in HTML)
you can almost do this with a stack:
<window ...>
    <stack flex="1">
       <image top="40" left="80"/>
       <vbox>
          other content here
       </vbox>
    </stack>
</window>
The only restriction is that your image can't overlap the right or bottom of the window. There are workarounds to this restriction by messing around with overflow or negative margins but I forgot offhand how to do that.
Request for a Thunderbird extension that can automatically detect the default domain when composing e-mails via autodetect.
<https://bugzilla.mozilla.org/show_bug.cgi?id=312818>
"Thunderbird requires domain in addresses and doesn't always add default"
There is an extension that allows what you want attached to one of the comments in this bug.

Friday, September 29 - October 6, 2006

(↑ top)

Is there anyway, via plugin or extension, for Firefox to mimic the functionality of IE in this respect?
The IETab (Opens IE in a Firefox tab) should be able do this if you set it to always open "file://*" URLs in an IE tab. The appearance with a FireFox tab isn't quite the same as having a completely separate Explorer window. However, it's functional and does allow for the Explorer to be handling the display of the folder contents, and all of the right-click context menu support is present so it should meet my needs.
What is the valid location and things needed to to release a Mozilla extension on Mozallia site?
You must remove updateURL from the install.rdf and use a known to AMO minVersion/maxVersion.
No confirmation that the answer given worked yet.
Is it possible to open the URL in a new tab?
var tab = gBrowser.addTab( url );
// And if you want it to load in the foreground:
gBrowser.selectedTab = tab;
Is it possible to read the html-code of the current URL/site?
Yes, this is possible. Use the DOM API (http://www.w3schools.com/dom/default.asp has a good tutorial).
Not the best answer but a good starting point for the question asker to do some research towards the answer.
Why does his extension not able to read the contents of a folder and then produce a segmentation fault after his extension reads preferences in Thunderbird?
The person was missing a method call to getService.

Friday, October 06 - 13, 2006

(↑ top)

Any suggestions to remove tool tip appears on the menu it when it should not?
What you described was a bug (https://bugzilla.mozilla.org/show_bug.cgi?id=147670). It looks like it has been fixed for Firefox version 2.
How to test a tab has been closed or not?
You can capture the even of tab closing. You can get the tab that is being closed. This should be enough for you.
Is it possible to fix the size exactly at 16x16 pixels avoiding any resize?
Simply position the image and it will no longer be stretched to the size of the stack. <image left="0" top="0"> would seem to suffice.
Could there be more than two images to reflect more than two states?
Does the rules in the CSS file have to be in any particular order (if two rules match, which is chosen)?
I have two states switching images in the tool bar and would have no problem implementing a third, so yes it's possible.

//setting the state document.getElementById("toolbar-button").setAttribute("toolbar-button", "on");
//or
document.getElementById("toolbar-button").setAttribute("toolbar-button","off");

//CSS

#myExten-toolbar-button[myExten-toolbar-button="on"] {
   list-style-image: url("chrome://myExten/skin/toolbar-button.png");
   -moz-image-region: rect(0px 24px 24px 0px);
}
 #myExten-toolbar-button[myExten-toolbar-button="off"] {
   list-style-image: url("chrome://myExten/skin/toolbar-button-off.png");
   -moz-image-region: rect(0px 24px 24px 0px);
}
To implement a third I would simply change add an attribute and the corresponding CSS
See http://www.w3.org/TR/REC-CSS2/cascade.html#cascade

Friday, October 13 - 20, 2006

(↑ top)

How to get a refenece to the sidebar window
Assuming you have chrome privileges, this should work:
var Ci = Components.interfaces;
var topLevelWindow = 
window.QueryInterface(Ci.nsIInterfaceRequestor)
       .getInterface(Ci.nsIWebNavigation)
       .QueryInterface(Ci.nsIDocShellTreeItem)
       .rootTreeItem
       .QueryInterface(Ci.nsIInterfaceRequestor)
       .getInterface(Ci.nsIDOMWindow)
       .QueryInterface(Ci.nsIDOMChromeWindow);
var sidebar = topLevelWindow.document.getElementById("sidebar");
alert(sidebar.contentDocument); 
Is there anyone successfully using Dojo in a Firefox extension and where to fine sample codes?
The problem with most JS frameworks is that they bootstrap by dynamically appending script elements, which doesn't work in XUL, last I checked. Take a look at the bottom of http://svn.dojotoolkit.org/dojo/trunk/dojo.js

see what it's trying to load and write out the script element by hand.

Could someone write an extension that would collapse the current sidebar in Firefox?
These are called "Grippies"
<https://addons.mozilla.org/firefox/2242/>

This extension brings grippies back to Firefox (and Thunderbird!)

Would anyone be able to suggest the best way to do source level debugging in a Firefox extension?
In the Debug menu, uncheck Exclude Browser Files.
Use the debugger by typing in a command like this: /break chrome://myextension/content/myfile.js 123
Then I suggest using flat chrome. If you turn off the XUL cache you don't even need to restart to see changes, simply open a new window.
How can I backup some of the files before upgrade an extension and put them back afterward? Do I need to write an installation script to achieve this?
You shouldn't store data there, so there's nothing to backup.
Do not store files within the extension directory.
The Profile directory is ment to do so.
Storing files within the extension directory is a no-no because it might break the multi-user support of those Mozilla products, as it is possible to install extensions directly within the application directory.
Inspector, Talkback and the default theme are nowadays installed like this.
Does Firefox clean up the preferences set by extension? If not, how to proceed?
When user chooses to uninstall an extension, a nsIObserverService notification is sent out. The problem is, while your extension is still active, user can cancel uninstallation, and when it is physically uninstalled, your code can't run.
Right. And if you uninstall Firefox, the profile data is left behind.
It would be nice to give the option of clearing extension's data, but it should be implemented at application level, not by each extension individually.
It might be an option to stick with it and perform stuff when it comes to application shutdown.
The Sanitize stuff does this (clean stuff on exit).
http://lxr.mozilla.org/mozilla1.8/so...ents/nsBrowser...
Firefox will clean all those preferences which are still "default", that is not changed by the user or the application/extension.
To provide those default preferences to your extension see: http://kb.mozillazine.org/Dev_:_Usin...lt_preferences
BTW: Resetting prefences to default will clear them in case no default prefence is (still) available.
Those will be completely removed upon next application launch.
Is it possible to create a sidebar on the top of the page?
Not unless you make it a separate window. There's a bug in bugzilla about stacking other widgets on top of browser/iframe, which hopefully will be fixed for Gecko 1.9.
Could someone write an extension that zaps the Google Analytics cookie, the Urchin cookie, switches Gmail and Google Calender to HTTPS?
CustomizeGoogle extension already has support for switching Gmail to HTTPS (and calendar possibly, too).
Does anyone know how write a bounce email extension?
Are you aware of the "mailredirect" extension? It allows bouncing to arbitrary addresses. It seems what you want is a one button access to that extension with a prefilled bounce address, right?
could someone make an extension for Thunderbird that preview upcomeing events and number of new messages?
In our company I write this extension that connects to our GroupWare server (HTTP). What server should souch extension work gainst? Did you mean Exchange?
How to attach information using the StringProperties of an IMAP message with out changing the properties?
String properties are implemented as IMAP user flags. However not all servers support user flags, in which case you get reduced functionality as follows: all flags are stored in your local cache and are lost if your cache gets invalidated, and only "known" properties are copied when messages are copied. The list of "known" properties is: junkscore junkscoreorigin label priority keywords.
Keywords - In the GUI they are called Tags. They replace the old Labels (although the labels are still recognised).
Preserved properties source code - nsImapMailFolder::CopyMessages

UAQ

Friday, September 22 - 29, 2006

(↑ top)

Friday, September 29 - October 6, 2006

(↑ top)

Friday, October 6 - 13, 2006

(↑ top)

Friday, October 13 - 20, 2006

(↑ top)

Document Tags and Contributors

 Contributors to this page: fscholz, Sheppy, RichardChu, Mckwan
 Last updated by: fscholz,