The javascript code in the overlay code does not work, because it works earlier than gbrowser contains any tabs.
In Firefox (or Thunderbird) extensions, you usually start the extension in the download event listener:
window.addEventListener("load", pinfresh.init, false);
Then, the init function should register event listeners for various tab events:
pub.init = function() { var container = gBrowser.tabContainer; container.addEventListener("TabOpen", tabOpened, false); container.addEventListener("TabClose", tabRemoved, false); };
When a new tab is opened, we register another listener that activates the reload of the tab when the user double-clicks the tab:
tabOpened = function(e) { var tab = e.target; tab.addEventListener("dblclick", tabDoubleClicked, false); } tabDoubleClicked = function(e) { gBrowser.reloadTab(e.target); }
The full code is as follows:
<overlay id="pinfresh" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script type="application/x-javascript"> pinfresh = function() { var pub = {}; tabOpened = function(e) { var tab = e.target; tab.addEventListener("dblclick", tabDoubleClicked, false); } tabRemoved = function(e) { var tab = e.target; tab.removeEventListener("dblclick", tabDoubleClicked, false); } tabDoubleClicked = function(e) { gBrowser.reloadTab(e.target); } pub.init = function() { var container = gBrowser.tabContainer; container.addEventListener("TabOpen", tabOpened, false); container.addEventListener("TabClose", tabRemoved, false); }; return pub; }(); window.addEventListener("load", pinfresh.init, false); </script> </overlay>
For snippets of code for working with tabs, I recommend the Tab Browser page in the Mozilla Development Center.
I recommend putting the Javascript code in your own file, and not including it in the XUL file. Errors in external Javascript files are displayed in the Firefox console, which simplifies debugging.