Questions and answers from the newsgroups 2006 11 03

  • Revision slug: Extensions/Questions_and_answers_from_the_newsgroups_2006_11_03
  • Revision title: Questions and answers from the newsgroups 2006 11 03
  • Revision id: 183676
  • Created:
  • Creator: Mckwan
  • Is current revision? No
  • Comment

Revision Content

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 : http://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 = "http://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

http://kb.mozillazine.org/Dev_:_Extending_the_Chrome_Protocol

If Components.classes{{mediawiki.external('\"@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 http://forums.mozillazine.org/viewtopic.php?p=1694347&sid=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: http://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.

====[http://groups.google.com/group/mozilla.dev.extensions/browse_frm/thread/77f96ad27ecb147a 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).

====[http://groups.google.com/group/mozilla.dev.extensions/browse_frm/thread/77d0446c76310404 How to create an overlay of msgHeaderOverlay.xul which removes the current collaspedHeaderView element and adds a new one?]====

use the DOM API to remove elements. http://developer.mozilla.org/en/docs/DOM:element.removeChild
How to execute then 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.
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.

UAQ

(↑ top)

Revision Source

<p><a href="en/Newsgroup_summaries/mozilla-dev-extensions"> Return to mozilla-dev-extensions</a>
</p><p><br> 
</p>
<h3 name="FAQ"> FAQ </h3>
<p>(<a href="#top">↑ top</a>)
</p>
<div class="note">
<h5 name="Is_there_any_way_to_view_Firefox_tab_title.3F"><a class="external" href="http://groups.google.com/group/mozilla.dev.extensions/browse_frm/thread/ff31e4037eb5065d">Is there any way to view Firefox tab title?</a></h5>
<dl><dd> Small tabs:
</dd></dl>
<pre class="eval"> 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
</pre>
<dl><dd> "Zoom": Put your mouse over the tab and a tooltip text should appear telling you the title for that tab. 
</dd></dl>
<dl><dd> Tab Preview : http://ted.mielczarek.org/code/mozilla/tabpreview/ 
</dd></dl>
</div>
<div class="note">
<h5 name="How_to_get_URL_form_address_bar.2C_redirect_and_update_list_from_a_central_server.3F"><a class="external" href="http://groups.google.com/group/mozilla.dev.extensions/browse_frm/thread/1f771289fe94a636">How to get URL form address bar, redirect and update list from a central server?</a></h5>
<dl><dd> 1. Get URL in address bar with document.location
</dd><dd> 2. There are many ways to do this, but assuming you have your list of addresses in an array:
</dd></dl>
<pre class="eval"> if (myURLArray.some(function(e, i, a) {return document.location.indexOf(e)&gt;-1;})) {
   // redirect
   document.location = "http://my.new.location.com";
 }
</pre>
<dl><dd> You might consider using a regular expression match instead of indexOf().
</dd><dd> 3. Use XmlHttpRequest()  to retrieve the file, then XMLSerializer.serializeToStream() to write to disk.
</dd></dl>
</div>
<div class="note">
<h5 name="How_to_screen_grab_use_the_command_line.3F"><a class="external" href="http://groups.google.com/group/mozilla.dev.extensions/browse_frm/thread/df139b7742eef728">How to screen grab use the command line?</a></h5>
<dl><dd> 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.
</dd></dl>
<dl><dd> 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
</dd></dl>
<p>http://kb.mozillazine.org/Dev_:_Extending_the_Chrome_Protocol
</p>
<dl><dd> If Components.classes{{mediawiki.external('\"@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 http://forums.mozillazine.org/viewtopic.php?p=1694347&amp;sid=518e2773c6c... if you don't understand it), and that there are no errors in the error console. 
</dd></dl>
<dl><dd> An extension is a bundle, which can provide various things, including chrome packages and components: http://developer.mozilla.org/en/docs/Bundles
</dd></dl>
<dl><dd> 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. 
</dd></dl>
</div>
<div class="note">
<p>====[http://groups.google.com/group/mozilla.dev.extensions/browse_frm/thread/77f96ad27ecb147a 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? ]====
</p>
<dl><dd> It's a lot easier to tunnel the HTTP connection over SSL using stunnel or openssl... no coding necessary.
</dd></dl>
<dl><dd> 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). 
</dd></dl>
</div>
<div class="note">
<p>====[http://groups.google.com/group/mozilla.dev.extensions/browse_frm/thread/77d0446c76310404 How to create an overlay of msgHeaderOverlay.xul which removes the current 
collaspedHeaderView element and adds a new one?]====
</p>
<dl><dd> use the DOM API to remove elements. http://developer.mozilla.org/en/docs/DOM:element.removeChild 
</dd></dl>
</div>
<div class="note">
<h5 name="How_to_execute_then_command_line_example_from_mozilla_site.3F"><a class="external" href="http://groups.google.com/group/mozilla.dev.extensions/browse_frm/thread/485a300f319d2b0e">How to execute then command line example from mozilla site?</a></h5>
<dl><dd> In order to cause auto-registration process, you'll also need to delete compreg.dat in your profile. 
</dd></dl>
<dl><dd> The call to nsICategory::addCategoryEntry in the example does it; but it's not related to the problem at hand. 
</dd></dl>
</div>
<div class="note">
<h5 name="Why_extensions_setup_has_all_locales_available_for_them.3F"><a class="external" href="http://groups.google.com/group/mozilla.dev.extensions/browse_frm/thread/85b6166e6a5ceb47">Why extensions setup has all locales available for them?</a></h5>
<dl><dd> This is a known issue and people are working on a fix. 
</dd></dl>
</div>
<div class="note">
<h5 name="someone_update_the_Session_Manager_extension_for_Firefox_2.3F"><a class="external" href="http://groups.google.com/group/mozilla.dev.extensions/browse_frm/thread/f0b79e4c542d4281Could">someone update the Session Manager extension for Firefox 2?</a></h5>
<dl><dd> FF 2.0 provides the following features of session manager out of the box:
</dd><dd> - restore the session after a crash
</dd><dd> - open closed tabs and windows (see History -&gt; recently closed tabs)
</dd><dd> - restore the session after restart
</dd><dd> - restore the session after new start (see Preferences -&gt; General -&gt; Start -&gt; ...)
</dd><dd> The only feature which is not covered is the rstoring of multiple saved sessions.
</dd></dl>
<dl><dd> 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. 
</dd></dl>
</div>
<h3 name="UAQ"> UAQ </h3>
<p>(<a href="#top">↑ top</a>)
</p>
<div class="note">
<h5 name="Is_there_any_way_to_forcing_nsWebBrowserPersist_service_to_finish_its_job.3F"><a class="external" href="http://groups.google.com/group/mozilla.dev.extensions/browse_frm/thread/15dfde8a554db572/8bf65f32526a7454#8bf65f32526a7454">Is there any way to forcing nsWebBrowserPersist service to finish its job?</a></h5>
</div>
<div class="note">
<h5 name="How_to_post_data_using_nsIWebNavigation.loadURI.3F"><a class="external" href="http://groups.google.com/group/mozilla.dev.extensions/browse_frm/thread/fc2e0450de6f8966">How to post data using nsIWebNavigation.loadURI?</a></h5>
</div>
<div class="note">
<h5 name="How_to_expose_a_JS_constructor_with_.28non-const.29_properties_to_content.3F"><a class="external" href="http://groups.google.com/group/mozilla.dev.extensions/browse_frm/thread/1ad4fd0ad2b9fcbd">How to expose a JS constructor with (non-const) properties to content?</a></h5>
</div>
<div class="note">
<h5 name="How_to_write_a_.aff_file.3F"><a class="external" href="http://groups.google.com/group/mozilla.dev.extensions/browse_frm/thread/9e170ab82ac856a2">How to write a .aff file?</a></h5>
</div>
Revert to this revision