mozilla

Revision 183670 of 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: 183670
  • 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.

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>
<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_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