Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Questions and answers from the newsgroups 2006 11 03

Return to mozilla-dev-extensions


FAQ

(↑ top)

Is there any way to view Firefox tab title?
Small tabs:
 1. Type: about:config to your address bar
 2. Type browser.tabs.tabMinWidth to filter
 3. Change value to something like 20 or smaller if you like
"Zoom": Put your mouse over the tab and a tooltip text should appear telling you the title for that tab.
Tab Preview : https://ted.mielczarek.org/code/mozilla/tabpreview/
How to get URL form address bar, redirect and update list from a central server?
1. Get URL in address bar with document.location
2. There are many ways to do this, but assuming you have your list of addresses in an array:
 if (myURLArray.some(function(e, i, a) {return document.location.indexOf(e)>-1;})) {
   // redirect
   document.location = "https://my.new.location.com";
 }
You might consider using a regular expression match instead of indexOf().
3. Use XmlHttpRequest() to retrieve the file, then XMLSerializer.serializeToStream() to write to disk.
How to screen grab use the command line?
There's no such thing as an "extension handle". Extension's functions can be defined in windows of certain type (e.g. browser.xul windows), in which case you need to get the window you need, e.g. using nsIWindowMediator.
Alternatively they can be defined in an XPCOM component, in which case you have to get your component via its contract id and either a) call a method on one of (IDL-defined) interfaces your component implements (you may need to create your own interface) or b) use the wrappedJSObject trick, which is, weirdly, not documented, but you can see it in the code on

https://kb.mozillazine.org/Dev_:_Exte...hrome_Protocol

If Components.classes["@your.name/yourcontractid"] returns null, your component wasn't registered. I don't think we have troubleshooting guide for XPCOM components registration, but you should at least check that you put the component's JS file in your extension's components/folder, that it has a proper XPCOM registration code (copy it from https://forums.mozillazine.org/viewto...id=518e2773c6c... if you don't understand it), and that there are no errors in the error console.
An extension is a bundle, which can provide various things, including chrome packages and components: https://developer.mozilla.org/en/docs/Bundles
After the extension is installed, mozilla will attempt to register its components on restart. It may fail to register them, in which case you'll indeed have the extension registered, but not the component.
Would it be possible to intercept the socket event and set the socket to be SSL enabled so that FF can communicate with an SSL speaking proxy?
It's a lot easier to tunnel the HTTP connection over SSL using stunnel or openssl... no coding necessary.
What you can do is set the network.http.default-socket-type preference and register a socket provider. However, you can only implement socket providers in C++... I suppose you could set that pref to "ssl", that might actually work (if you also set your HTTP proxy to something that accepts SSL).
How to execute the command line example from mozilla site?
In order to cause auto-registration process, you'll also need to delete compreg.dat in your profile.
The call to nsICategory::addCategoryEntry in the example does it; but it's not related to the problem at hand.
Why extensions setup has all locales available for them?
This is a known issue and people are working on a fix.
Could someone update the Session Manager extension for Firefox 2?
FF 2.0 provides the following features of session manager out of the box:
- restore the session after a crash
- open closed tabs and windows (see History -> recently closed tabs)
- restore the session after restart
- restore the session after new start (see Preferences -> General -> Start -> ...)
The only feature which is not covered is the rstoring of multiple saved sessions.
You can use Bookmarks for that. Just create a folder with all the places You want to visit at once. Then You can pick Open All in Tabs from folders contaxt menu to open all of bookmarks in that folder.
How to create a web installable firefox extension?
place extension somewhere on the www
How to add two buttons to tabs-bar, or to buttons-bar to use as bookmarks button?
Install PrefBar from <https://prefbar.mozdev.org/>. Create a new PrefBar button named Bkmarks. In the onClick window, enter BrowserEditBookmarks(); Enable the button.
If you select the button, it will open Bookmarks Manager with its tree structure. That will allow you to select a bookmark to view the indicated Web page. That will also allow you to drag and drop the address of the current page into the bookmarks exactly where you want it.
If you merely want to see your bookmarks, do what I (and many others) do: Make your bookmarks.html file your home page. On the menu bar, select [Edit > Preferences]. Under Category on the Preferences window, select Navigator. On the Navigator pane, under Home Page, select the Choose File button. On the Choose Home Page window, navigate to your profile and select bookmarks.html. Then, every time you select Home, you will get your bookmarks displayed as a Web page.
How to using the "wrappedJSObject" in an XPCOM component?
The "wrappedJSObject" property is just a way to get to the underlying JSObject of XPCOM components implemented in JavaScript. Presumably in most cases you're better off defining an interface to your component and then accessing it through that interface.
https://developer.mozilla.org/en/docs...COM_Component_...
The only thing to do differently from this example is to retrieve your component via getService rather than createInstance.
The uuidgen command-line tool, available (at least) on Mac OS X and in many Linux distributions (perhaps only with optional installation), will generate one of these. You can also get one by sending the message "uuid" to ssdbot on irc.mozilla.org. Or google "generate uuid" to find online generators.
Extension developer's best friend Ted Mielczarek is working on a component wizard. Dev version is here: https://mavra.perilith.com/~luser/jscomponentwiz/ The "Create as a service" checkbox doesn't work currently, but otherwise it's a very nice tool.
Is there is way to detect if a fellow extension is currently installed and enabled?
An easy way to do it is to test if an id is present from the extension.
For example:
 test = document.getElementById('myownextensionID');
 if (test) {
    // now you know it found the element so the extension must be present
 }

UAQ

(↑ top)

How to post data using nsIWebNavigation.loadURI?

Answer for java :


  First you have to initialize xulrunner, the shell, the display and the browser
  Have a look at the xpcom and swt documentation if needed, a good example is the IBM Snippet267 
  A google search will give us a good example of a data post, so  
  during the browser initialisation lets run : browser.setUrl("https://www.google.fr");


  //Get the nsIWebNavigation interface
  nsIWebBrowser webBrowser = (nsIWebBrowser)browser.getWebBrowser();
  nsIWebNavigation navigation =  (nsIWebNavigation)webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
  //When calling nsIWebNavigation.loadURI, you can call a javascript script
  //post data to fill the text input
  String inputFillScript = "javascript:" + "document.forms.f.q.value = 'calculette'" + ";void(0);";
  navigation.loadURI(inputFillScript, nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null); 
  //The google search text input is now filled with 'calculette'
  //post data to submit the form
  String submitFormScript =  "javascript:" + "document.forms.f.submit()" + ";void(0);";
  navigation.loadURI(url2, nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null); 
  //the page has changed : it shows the search results for the word 'calculette'

Document Tags and Contributors

 Contributors to this page: Calculette, RichardChu, Aconbere, Mckwan
 Last updated by: Calculette,