Announce and Discuss the Latest Theme and Extension Releases.
SevenSeven
Posts: 33Joined: February 8th, 2004, 1:05 pm
Posted December 1st, 2009, 4:44 pm
Here's some of my code that someone might find useful. Works with Firefox 3.5-3.6. - Clear the searchbar after submit & open in new fg tab or current tab if blank (must set browser.search.openintab = false)
- Auto context menu on selection (much improved from my last posting of this)
- Open urlbar queries in new fg tab or in current tab if blank
- Open bookmark-menu URIs in new fg tab or in current tab if blank
- Open history-menu URIs in new fg tab or in current tab if blank
- Open external app links in new tab or in current tab if blank
- Code: Select all
if (location == "chrome://browser/content/browser.xul") {
/*======= Clear the searchbar after submit & open in new fg tab or current tab if blank (browser.search.openintab = false) =======*/
var ucSearchbar = { controller: null, popupAC_bool: false,
init: function() { this.searchbar = document.getElementById("searchbar"); if (!this.searchbar) return; var searchbarTextbox = document.getAnonymousElementByAttribute(this.searchbar, "anonid", "searchbar-textbox"); searchbarTextbox.addEventListener("keydown", function(event) { ucSearchbar.onKeydown(event); }, false);
var searchGoButton = document.getAnonymousElementByAttribute(this.searchbar, "anonid", "search-go-button"); searchGoButton.addEventListener("mousedown", function(event) { ucSearchbar.onMousedown(event); }, false); searchGoButton.addEventListener("click", function(event) { ucSearchbar.onClick(event); }, false);
if (this.controller) return; this.controller = Components.classes["@mozilla.org/autocomplete/controller;1"].getService(Components.interfaces.nsIAutoCompleteController); var popupAC = document.getElementById("PopupAutoComplete"); this.acPopup = popupAC.QueryInterface(Components.interfaces.nsIAutoCompletePopup); popupAC.addEventListener("mousedown", function(event) { ucSearchbar.popupAC_onMousedown(event); }, false); popupAC.addEventListener("click", function(event) { ucSearchbar.popupAC_onClick(event); }, false); },
onKeydown: function(event) { if (event.keyCode == 13) { this.tabFunc(); setTimeout("ucSearchbar.searchbar.value='';", 0); } },
onMousedown: function(event) { this.tabFunc(); },
tabFunc: function() { if (gBrowser.currentURI.spec != 'about:blank' || gBrowser.webProgress.isLoadingDocument) { gBrowser.selectedTab = gBrowser.addTab(); this.searchbar.focus(); } },
onClick: function(event) { setTimeout("ucSearchbar.searchbar.value='';", 0); },
popupAC_onMousedown: function(event) { if (this.controller.input.searchParam != "searchbar-history") return; this.searchbar.value = this.controller.getValueAt(this.acPopup.selectedIndex); this.tabFunc(); popupAC_bool = true; },
popupAC_onClick: function(event) { if (!popupAC_bool) return; this.onClick(event); popupAC_bool = false; } }; ucSearchbar.init(); eval("BrowserToolboxCustomizeDone = " + BrowserToolboxCustomizeDone.toString().replace('window.f','ucSearchbar.init(); $&'));
/*======= Auto context menu on selection =======*/
var autoContextmenu = { onMousedown: function(event) { if (event.button != 0 || !(event.originalTarget.ownerDocument instanceof HTMLDocument)) return; this.selection = content.getSelection(); if (!this.selection.isCollapsed) //prevent popup on click w/in the selection this.selection.removeAllRanges(); },
onMouseup: function(event) { if (event.button != 0 || !(event.originalTarget.ownerDocument instanceof HTMLDocument)) return; if (this.selection.isCollapsed || !/\S/.test(this.selection.toString()) //prevent popup if selection contains only white space (eg, clicking embed'd flash) || /^https...mail\.go|buch\.rev|ebay.com\//.test(gBrowser.currentURI.spec)) return; //exclude gmail compose, woerterbuch.reverso.net, ebay var mouseEvent = document.createEvent("MouseEvents"); mouseEvent.initMouseEvent("contextmenu", true, true, window, 1, event.screenX, event.screenY, event.clientX, event.clientY, false, false, false, false, 2, null); event.target.dispatchEvent(mouseEvent); },
hide: function() { if (gContextMenu) gContextMenu.menu.hidePopup(); } }; document.addEventListener("mousedown", function(event) { autoContextmenu.onMousedown(event); }, true); document.addEventListener("mouseup", function(event) { autoContextmenu.onMouseup(event); }, false); document.addEventListener("TextLinkServiceOpenClickedURI", autoContextmenu.hide, false);
/*======= Open urlbar queries in new fg tab or in current tab if blank =======*/
var urlbarInput = { handle: function(aTriggeringEvent) { if (aTriggeringEvent instanceof MouseEvent && aTriggeringEvent.button == 2) return; // Do nothing for right clicks
var [url, postData] = gURLBar._canonizeURL(aTriggeringEvent); if (!url) return;
gURLBar.value = url; gBrowser.userTypedValue = url; try { addToUrlbarHistory(url); } catch (ex) { // Things may go wrong when adding url to session history, // but don't let that interfere with the loading of the url. Cu.reportError(ex); }
if (aTriggeringEvent instanceof MouseEvent) { if ((gBrowser.currentURI.spec != 'about:blank' || gBrowser.webProgress.isLoadingDocument) && (aTriggeringEvent == null || (!aTriggeringEvent.ctrlKey && !aTriggeringEvent.shiftKey && !aTriggeringEvent.altKey))) { gURLBar.handleRevert(); content.focus(); gBrowser.selectedTab = gBrowser.addTab(); } // We have a mouse event (from the go button), so use the standard // UI link behaviors openUILink(url, aTriggeringEvent, false, false, true /* allow third party fixup */, postData); return; }
if ((gBrowser.currentURI.spec != 'about:blank' || gBrowser.webProgress.isLoadingDocument) && (aTriggeringEvent == null || (!aTriggeringEvent.ctrlKey && !aTriggeringEvent.shiftKey))) { gURLBar.handleRevert(); content.focus(); gBrowser.loadOneTab(url, null, null, postData, false, true /* allow third party fixup */); aTriggeringEvent.preventDefault(); aTriggeringEvent.stopPropagation(); } else loadURI(url, null, postData, true /* allow third party fixup */);
focusElement(content); } }; document.getElementById("urlbar").setAttribute("ontextentered","urlbarInput.handle(param);"); document.getElementById("go-button").setAttribute("onclick","urlbarInput.handle(event);");
/*======= Open bookmark-menu URIs in new fg tab or in current tab if blank =======*/
eval("PlacesUIUtils.openNodeIn = " + PlacesUIUtils.openNodeIn.toString().replace('openU','if ((gBrowser.currentURI.spec != "about:blank" || gBrowser.webProgress.isLoadingDocument) && !/^j/.test(aNode.uri) && aWhere == "current") aWhere = "tab"; $&')); //http://forums.mozillazine.org/viewtopic.php?p=3201065#3201065 eval("PlacesUIUtils._openTabset = " + PlacesUIUtils._openTabset.toString().replace('ue;','$& var tabBrowser = null; if (browserWindow) tabBrowser = browserWindow.getBrowser(); if (tabBrowser && (tabBrowser.currentURI.spec != "about:blank" || tabBrowser.webProgress.isLoadingDocument)) replaceCurrentTab = false;'));
/*======= Open history-menu URIs in new fg tab or in current tab if blank =======*/
document.getElementById("history-menu").setAttribute("oncommand","var node = event.target.node; if (node) { PlacesUIUtils.markPageAsTyped(node.uri); if ((gBrowser.currentURI.spec != 'about:blank' || gBrowser.webProgress.isLoadingDocument) && (event == null || (!event.ctrlKey && !event.shiftKey && !event.altKey))) { gBrowser.selectedTab = gBrowser.addTab(); } openUILink(node.uri, event, false, true); }");
/*======= Open external app links in new tab or in current tab if blank =======*/
eval('nsBrowserAccess.prototype.openURI = ' + nsBrowserAccess.prototype.openURI.toString().replace('b =','$& (win.gBrowser.currentURI.spec == "about:blank" && !win.gBrowser.webProgress.isLoadingDocument) ? win.gBrowser.mCurrentTab :'));
} //chrome://browser/content/browser.xul
aronin
Posts: 243Joined: November 9th, 2005, 7:31 pm
Posted December 1st, 2009, 4:58 pm
SevenSeven wrote:Here's some of my code that someone might find useful. Works with Firefox 3.5-3.6. - Clear the searchbar after submit & open in new fg tab or current tab if blank (must set browser.search.openintab = false)
- Auto context menu on selection (much improved from my last posting of this)
- Open urlbar queries in new fg tab or in current tab if blank
- Open bookmark-menu URIs in new fg tab or in current tab if blank
- Open history-menu URIs in new fg tab or in current tab if blank
- Open external app links in new tab or in current tab if blank
This is an excellent All-In-One script. Thank you so much.
Domthedude001

Posts: 32Joined: April 28th, 2008, 2:16 pm
Posted December 26th, 2009, 3:23 am
Is there a code to make the "Done" in the statusbar (which should also work with Fission) display the page title instead? If so, please post 
Last edited by Domthedude001 on January 16th, 2010, 11:17 pm, edited 1 time in total.
allenwalker31
Posts: 1Joined: January 1st, 2010, 2:07 am
Posted January 1st, 2010, 2:10 am
I want to know how to edit about:config setting through userchrome.js because I can't change the settings no matter what, but since I'm a noob at this I want some help » I wan to change the value of network.http.max-connections-per-server to 24 and network.http.max-persistent-connections-per-server to 12
aronin
Posts: 243Joined: November 9th, 2005, 7:31 pm
Posted March 22nd, 2010, 9:39 pm
SevenSeven wrote:Here's some of my code that someone might find useful. Works with Firefox 3.5-3.6. - Clear the searchbar after submit & open in new fg tab or current tab if blank (must set browser.search.openintab = false)
- Auto context menu on selection (much improved from my last posting of this)
- Open urlbar queries in new fg tab or in current tab if blank
- Open bookmark-menu URIs in new fg tab or in current tab if blank
- Open history-menu URIs in new fg tab or in current tab if blank
- Open external app links in new tab or in current tab if blank
- Code: Select all
if (location == "chrome://browser/content/browser.xul") {
/*======= Clear the searchbar after submit & open in new fg tab or current tab if blank (browser.search.openintab = false) =======*/
var ucSearchbar = { controller: null, popupAC_bool: false,
init: function() { this.searchbar = document.getElementById("searchbar"); if (!this.searchbar) return; var searchbarTextbox = document.getAnonymousElementByAttribute(this.searchbar, "anonid", "searchbar-textbox"); searchbarTextbox.addEventListener("keydown", function(event) { ucSearchbar.onKeydown(event); }, false);
var searchGoButton = document.getAnonymousElementByAttribute(this.searchbar, "anonid", "search-go-button"); searchGoButton.addEventListener("mousedown", function(event) { ucSearchbar.onMousedown(event); }, false); searchGoButton.addEventListener("click", function(event) { ucSearchbar.onClick(event); }, false);
if (this.controller) return; this.controller = Components.classes["@mozilla.org/autocomplete/controller;1"].getService(Components.interfaces.nsIAutoCompleteController); var popupAC = document.getElementById("PopupAutoComplete"); this.acPopup = popupAC.QueryInterface(Components.interfaces.nsIAutoCompletePopup); popupAC.addEventListener("mousedown", function(event) { ucSearchbar.popupAC_onMousedown(event); }, false); popupAC.addEventListener("click", function(event) { ucSearchbar.popupAC_onClick(event); }, false); },
onKeydown: function(event) { if (event.keyCode == 13) { this.tabFunc(); setTimeout("ucSearchbar.searchbar.value='';", 0); } },
onMousedown: function(event) { this.tabFunc(); },
tabFunc: function() { if (gBrowser.currentURI.spec != 'about:blank' || gBrowser.webProgress.isLoadingDocument) { gBrowser.selectedTab = gBrowser.addTab(); this.searchbar.focus(); } },
onClick: function(event) { setTimeout("ucSearchbar.searchbar.value='';", 0); },
popupAC_onMousedown: function(event) { if (this.controller.input.searchParam != "searchbar-history") return; this.searchbar.value = this.controller.getValueAt(this.acPopup.selectedIndex); this.tabFunc(); popupAC_bool = true; },
popupAC_onClick: function(event) { if (!popupAC_bool) return; this.onClick(event); popupAC_bool = false; } }; ucSearchbar.init(); eval("BrowserToolboxCustomizeDone = " + BrowserToolboxCustomizeDone.toString().replace('window.f','ucSearchbar.init(); $&'));
/*======= Auto context menu on selection =======*/
var autoContextmenu = { onMousedown: function(event) { if (event.button != 0 || !(event.originalTarget.ownerDocument instanceof HTMLDocument)) return; this.selection = content.getSelection(); if (!this.selection.isCollapsed) //prevent popup on click w/in the selection this.selection.removeAllRanges(); },
onMouseup: function(event) { if (event.button != 0 || !(event.originalTarget.ownerDocument instanceof HTMLDocument)) return; if (this.selection.isCollapsed || !/\S/.test(this.selection.toString()) //prevent popup if selection contains only white space (eg, clicking embed'd flash) || /^https...mail\.go|buch\.rev|ebay.com\//.test(gBrowser.currentURI.spec)) return; //exclude gmail compose, woerterbuch.reverso.net, ebay var mouseEvent = document.createEvent("MouseEvents"); mouseEvent.initMouseEvent("contextmenu", true, true, window, 1, event.screenX, event.screenY, event.clientX, event.clientY, false, false, false, false, 2, null); event.target.dispatchEvent(mouseEvent); },
hide: function() { if (gContextMenu) gContextMenu.menu.hidePopup(); } }; document.addEventListener("mousedown", function(event) { autoContextmenu.onMousedown(event); }, true); document.addEventListener("mouseup", function(event) { autoContextmenu.onMouseup(event); }, false); document.addEventListener("TextLinkServiceOpenClickedURI", autoContextmenu.hide, false);
/*======= Open urlbar queries in new fg tab or in current tab if blank =======*/
var urlbarInput = { handle: function(aTriggeringEvent) { if (aTriggeringEvent instanceof MouseEvent && aTriggeringEvent.button == 2) return; // Do nothing for right clicks
var [url, postData] = gURLBar._canonizeURL(aTriggeringEvent); if (!url) return;
gURLBar.value = url; gBrowser.userTypedValue = url; try { addToUrlbarHistory(url); } catch (ex) { // Things may go wrong when adding url to session history, // but don't let that interfere with the loading of the url. Cu.reportError(ex); }
if (aTriggeringEvent instanceof MouseEvent) { if ((gBrowser.currentURI.spec != 'about:blank' || gBrowser.webProgress.isLoadingDocument) && (aTriggeringEvent == null || (!aTriggeringEvent.ctrlKey && !aTriggeringEvent.shiftKey && !aTriggeringEvent.altKey))) { gURLBar.handleRevert(); content.focus(); gBrowser.selectedTab = gBrowser.addTab(); } // We have a mouse event (from the go button), so use the standard // UI link behaviors openUILink(url, aTriggeringEvent, false, false, true /* allow third party fixup */, postData); return; }
if ((gBrowser.currentURI.spec != 'about:blank' || gBrowser.webProgress.isLoadingDocument) && (aTriggeringEvent == null || (!aTriggeringEvent.ctrlKey && !aTriggeringEvent.shiftKey))) { gURLBar.handleRevert(); content.focus(); gBrowser.loadOneTab(url, null, null, postData, false, true /* allow third party fixup */); aTriggeringEvent.preventDefault(); aTriggeringEvent.stopPropagation(); } else loadURI(url, null, postData, true /* allow third party fixup */);
focusElement(content); } }; document.getElementById("urlbar").setAttribute("ontextentered","urlbarInput.handle(param);"); document.getElementById("go-button").setAttribute("onclick","urlbarInput.handle(event);");
/*======= Open bookmark-menu URIs in new fg tab or in current tab if blank =======*/
eval("PlacesUIUtils.openNodeIn = " + PlacesUIUtils.openNodeIn.toString().replace('openU','if ((gBrowser.currentURI.spec != "about:blank" || gBrowser.webProgress.isLoadingDocument) && !/^j/.test(aNode.uri) && aWhere == "current") aWhere = "tab"; $&')); //http://forums.mozillazine.org/viewtopic.php?p=3201065#3201065 eval("PlacesUIUtils._openTabset = " + PlacesUIUtils._openTabset.toString().replace('ue;','$& var tabBrowser = null; if (browserWindow) tabBrowser = browserWindow.getBrowser(); if (tabBrowser && (tabBrowser.currentURI.spec != "about:blank" || tabBrowser.webProgress.isLoadingDocument)) replaceCurrentTab = false;'));
/*======= Open history-menu URIs in new fg tab or in current tab if blank =======*/
document.getElementById("history-menu").setAttribute("oncommand","var node = event.target.node; if (node) { PlacesUIUtils.markPageAsTyped(node.uri); if ((gBrowser.currentURI.spec != 'about:blank' || gBrowser.webProgress.isLoadingDocument) && (event == null || (!event.ctrlKey && !event.shiftKey && !event.altKey))) { gBrowser.selectedTab = gBrowser.addTab(); } openUILink(node.uri, event, false, true); }");
/*======= Open external app links in new tab or in current tab if blank =======*/
eval('nsBrowserAccess.prototype.openURI = ' + nsBrowserAccess.prototype.openURI.toString().replace('b =','$& (win.gBrowser.currentURI.spec == "about:blank" && !win.gBrowser.webProgress.isLoadingDocument) ? win.gBrowser.mCurrentTab :'));
} //chrome://browser/content/browser.xul
For 'Open URLs in New Tab', how can we change the code so that Javascripts open in the same tab instead of a new tab? Because typically JS is supposed to act on the current active tab. With this code, JS opens a new blank tab.
aronin
Posts: 243Joined: November 9th, 2005, 7:31 pm
Posted March 23rd, 2010, 10:56 am
Simple code to open URLs from address bar in a New Tab instead of over-writing the current active tab. - Code: Select all
(function() {urlbar = document.getElementById("urlbar"); eval("urlbar.handleCommand = " + urlbar.handleCommand.toString().replace("&& aTriggeringEvent.altKey","&& !aTriggeringEvent.altKey")); })();
from http://www.x2b4.com/
Alice0775
Posts: 2765Joined: October 26th, 2007, 11:25 pm
Posted July 1st, 2010, 5:51 pm
The following modified version works with Minefield 4.0b2pre. userchrome.js-0.8.010070203-Fx4.0.xpi[note]Not for Version1.1. edit version 0.8.010070203
Last edited by Alice0775 on July 2nd, 2010, 8:57 am, edited 1 time in total.
GOLF-AT
Posts: 18Joined: December 31st, 2007, 11:11 am
Posted July 2nd, 2010, 6:03 am
alta88
Posts: 1022Joined: January 28th, 2006, 3:08 pm
Posted July 2nd, 2010, 7:40 pm
could you post a patch? i will incorporate into the mozdev version.
aronin
Posts: 243Joined: November 9th, 2005, 7:31 pm
Posted July 5th, 2010, 2:30 pm
Super Drag'n'Drop code is broken with the latest nightly builds... can anyone please help.. - Code: Select all
/* :::::::::::::::::: Drag'n'go (cf. Super DragAndGo and QuickDrag) ::::::::::::::::::::: */
({ init: function() { var self = this; getBrowser().mPanelContainer.addEventListener("draggesture", function(aEvent) { nsDragAndDrop.startDrag(aEvent, self); }, true); gBrowser.mPanelContainer.addEventListener("dragover", function(aEvent) { nsDragAndDrop.dragOver(aEvent, self); }, false); if (Components.classes["@mozilla.org/xpcom/version-comparator;1"].getService(Components.interfaces.nsIVersionComparator).compare(Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULAppInfo).platformVersion, "1.9.1a2") > 0) { gBrowser.mPanelContainer.addEventListener("drop", function(aEvent) { if (!aEvent.dataTransfer.mozGetDataAt("application/x-moz-tabbrowser-tab", 0)) { self._wrapDrop(aEvent); } }, false); } else // Firefox 2.0 and 3.0 { gBrowser.mPanelContainer.addEventListener("dragdrop", function(aEvent) { self._wrapDrop(aEvent); }, false); } },
_wrapDrop: function(aEvent) { this._orig_checkCanDrop = nsDragAndDrop.checkCanDrop try { nsDragAndDrop.checkCanDrop = this._checkCanDrop; nsDragAndDrop.drop(aEvent, this); } finally { nsDragAndDrop.checkCanDrop = this._orig_checkCanDrop; } },
_checkCanDrop: function(aEvent, aDragDropObserver) { if (this.mDragSession || (this.mDragSession = this.mDragService.getCurrentSession())) { this.mDragSession.canDrop = true; } return this.mDragSession; },
onDragStart: function(aEvent, aXferData, aDragAction) { var target = aEvent.originalTarget; if (!(target instanceof HTMLImageElement && target.src)) { return; } for (var obj = target.parentNode; obj && !obj.href; obj = obj.parentNode); var url = obj ? obj.href : target.src; var caption = (obj ? obj.title : null) || target.title || target.alt || url.replace(/^.*\//, "") || url; aXferData.data = new TransferData(); aXferData.data.addDataForFlavour("text/x-moz-url", url + "\n" + caption); aXferData.data.addDataForFlavour("text/unicode", url); aXferData.data.addDataForFlavour("text/html", "<a href=\"" + url + "\">" + caption + "</a>"); },
onDragOver: function(aEvent, aFlavour, aDragSession) { aDragSession.canDrop = true; aEvent.preventDefault(); },
onDrop: function(aEvent, aXferData, aDragSession) { var url = this._getDroppedURL(aDragSession, 0); if (!url) { return; } aEvent.preventDefault(); var isLocalXPI = /^file:\/{3}(?:.*\/)?(.+\.xpi)$/; if (isLocalXPI.test(url)) // local XPI -> installation { var xpinstallObj = {}; xpinstallObj[RegExp.$1] = url; for (var i = 1; i < aDragSession.numDropItems; i++) { // allow to install several extensions at once if ((url = this._getDroppedURL(aDragSession, i)) && isLocalXPI.test(url)) { xpinstallObj[RegExp.$1] = url; } } InstallTrigger.install(xpinstallObj); return; } if (aDragSession.numDropItems == 1 && !/^file:\/{3}\S+|^data:.+|^(?:h?t|f)tps?:\/\/\S+$|^(?:(?:\w[\w-]*\.)+\w{2,7}|localhost)(?:[:\/]\S*)?$/.test(url)) // text string -> web search { var search = Components.classes["@mozilla.org/browser/search-service;1"].getService(Components.interfaces.nsIBrowserSearchService).defaultEngine.getSubmission(url, null); var postData = search.postData; url = search.uri.spec; } else if (/^ttps?:/.test(url)) { url = "h" + url; } gBrowser.dragDropSecurityCheck(aEvent, aDragSession, url); if (gBrowser.currentURI.spec == "about:blank" && !gBrowser.webProgress.isLoadingDocument) { loadURI(url, null, postData); } else { var newTab = gBrowser.addTab(url, gBrowser.currentURI, null, postData); if (gPrefService.getBoolPref("browser.tabs.loadInBackground") != !(aEvent && aEvent.shiftKey)) { gBrowser.selectedTab = newTab; } } for (i = 1; i < aDragSession.numDropItems; i++) { if ((url = this._getDroppedURL(aDragSession, i))) { gBrowser.dragDropSecurityCheck(aEvent, aDragSession, url); gBrowser.addTab(url, gBrowser.currentURI); } } },
_getDroppedURL: function(aDragSession, aIx) { try { var xfer = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable); xfer.addDataFlavor("text/x-moz-url"); xfer.addDataFlavor("text/unicode"); aDragSession.getData(xfer, aIx); var flavour = {}, data = {}, length = {}; xfer.getAnyTransferData(flavour, data, length); var xferData = new FlavourData(data.value, length.value, this.getSupportedFlavours().flavourTable[flavour.value]); return transferUtils.retrieveURLFromData(xferData.data, xferData.flavour.contentType); } catch (ex) { return null; } },
getSupportedFlavours: function() { var flavourSet = new FlavourSet(); flavourSet.appendFlavour("text/x-moz-url"); flavourSet.appendFlavour("text/unicode"); return flavourSet; } }).init();
Alice0775
Posts: 2765Joined: October 26th, 2007, 11:25 pm
Posted July 13th, 2010, 5:57 am
alta88 wrote:could you post a patch? i will incorporate into the mozdev version.
Patch for userChromeJS1.1 - Code: Select all
diff -b -U 8 -r org/chrome.manifest new/chrome.manifest --- org/chrome.manifest 2008-12-17 13:49:10.000000000 +0900 +++ new/chrome.manifest 2010-07-03 21:42:06.000000000 +0900 @@ -1,3 +1,6 @@ content userchromejs content/ -#skin userchromejs skin/ locale userchromejs en-US locale/en-US/ + +component {8DEB3B5E-7585-4029-B6D0-4733CE8DED50} components/userChrome_js.js appversion>=4.0b2pre +contract @userChromeJS;1 {8DEB3B5E-7585-4029-B6D0-4733CE8DED50} appversion>=4.0b2pre +category profile-after-change @userChromeJS;1 @userChromeJS;1 appversion>=4.0b2pre diff -b -U 8 -r org/components/userChrome_js.js new/components/userChrome_js.js --- org/components/userChrome_js.js 2009-05-11 08:42:16.000000000 +0900 +++ new/components/userChrome_js.js 2010-07-03 21:42:34.000000000 +0900 @@ -36,90 +36,66 @@ * * ***** END LICENSE BLOCK ***** */ const Cc = Components.classes; const Ci = Components.interfaces; const Cr = Components.results; const Cu = Components.utils; -const UserChrome_js = { - mCID: Components.ID("{8DEB3B5E-7585-4029-B6D0-4733CE8DED50}"), - mContractID: "@userChromeJS;1", - mClassName: "userChromeJS Loading Component", - mCategory: "m-userChromeJS", +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -/* ........ nsIModule ....................................................... */ - - getClassObject: function(aCompMgr, aCID, aIID) { - if (!aCID.equals(this.mCID)) { - Components.returnCode = Cr.NS_ERROR_FACTORY_NOT_REGISTERED; - return null; - } - - return this.QueryInterface(aIID); - }, - - registerSelf: function(aCompMgr, aFileSpec, aLocation, aType) { - aCompMgr.QueryInterface(Ci.nsIComponentRegistrar). - registerFactoryLocation(this.mCID, - this.mCategory, - this.mContractID, - aFileSpec, - aLocation, - aType); - - Cc["@mozilla.org/categorymanager;1"]. - getService(Ci.nsICategoryManager). - addCategoryEntry("app-startup", - this.mClassName, - "service," + this.mContractID, - true, - true); - }, - - unregisterSelf: function(aCompMgr, aLocation, aType) { - aCompMgr.QueryInterface(Ci.nsIComponentRegistrar). - unregisterFactoryLocation(this.mCID, - aLocation); - - Cc["@mozilla.org/categorymanager;1"]. - getService(Ci.nsICategoryManager). - deleteCategoryEntry("app-startup", - "service," + this.mContractID, - true); - }, - - canUnload: function(aCompMgr) { - return true; - }, +// Gecko 1.9.0/1.9.1 compatibility - add XPCOMUtils.defineLazyServiceGetter +if (!("defineLazyServiceGetter" in XPCOMUtils)) +{ + XPCOMUtils.defineLazyServiceGetter = function XPCU_defineLazyServiceGetter(obj, prop, contract, iface) + { + obj.__defineGetter__(prop, function XPCU_serviceGetter() + { + delete obj[prop]; + return obj[prop] = Cc[contract].getService(Ci[iface]); + }); + }; +} -/* ........ nsIFactory ...................................................... */ +function UserChrome_js() { +} - createInstance: function(aOuter, aIID) { - if (aOuter != null) { - Components.returnCode = Cr.NS_ERROR_NO_AGGREGATION; - return null; - } +UserChrome_js.prototype = { + // properties required for XPCOM registration: + classDescription: "userChromeJS Loading Component", + classID : Components.ID("{8DEB3B5E-7585-4029-B6D0-4733CE8DED50}"), + contractID : "@userChromeJS;1", + + _xpcom_categories: [{ + category: "app-startup", + service: true + }], - return this.QueryInterface(aIID); - }, +/* ........ QueryInterface .................................................. */ - lockFactory: function(aLock) { }, + QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsISupports, + Components.interfaces.nsIObserver, + Components.interfaces.nsIModule, + Components.interfaces.nsIFactory, + Components.interfaces.nsIDOMEventListener]), /* ........ nsIObserver ..................................................... */ observe: function(aSubject, aTopic, aData) { var os = Cc["@mozilla.org/observer-service;1"]. getService(Ci.nsIObserverService); switch (aTopic) { case "app-startup": os.addObserver(this, "final-ui-startup", false); break; + case "profile-after-change": + os.addObserver(this, "final-ui-startup", false); + break; case "final-ui-startup": var file = Cc["@mozilla.org/file/directory_service;1"]. getService(Ci.nsIProperties). get("UChrm", Ci.nsILocalFile); file.append("userChrome.js"); if (!file.exists()) { var componentFile = __LOCATION__; @@ -167,26 +143,20 @@ // script execution can be stopped with |throw "stop";| if (ex !== "stop") { Cu.reportError(ex); } } } }, -/* ........ QueryInterface .................................................. */ - - QueryInterface: function(aIID) { - if (!aIID.equals(Ci.nsISupports) && !aIID.equals(Ci.nsIModule) && - !aIID.equals(Ci.nsIFactory) && !aIID.equals(Ci.nsIObserver) && - !aIID.equals(Ci.nsIDOMEventListener)) { - Components.returnCode = Cr.NS_ERROR_NO_INTERFACE; - return null; - } - - return this; - }, - }; -function NSGetModule(aComMgr, aFileSpec) { - return UserChrome_js; -} +// The following line is what XPCOM uses to create components. Each component prototype +// must have a .classID which is used to create it. +/** +* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4). +* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6). +*/ +if (XPCOMUtils.generateNSGetFactory) + var NSGetFactory = XPCOMUtils.generateNSGetFactory([UserChrome_js]); +else + var NSGetModule = XPCOMUtils.generateNSGetModule([UserChrome_js]); diff -b -U 8 -r org/install.rdf new/install.rdf --- org/install.rdf 2009-05-22 19:18:34.000000000 +0900 +++ new/install.rdf 2010-07-03 21:54:11.799000000 +0900 @@ -1,34 +1,34 @@ <?xml version="1.0"?> <RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#"> <Description about="urn:mozilla:install-manifest"> <em:id>userChromeJS@mozdev.org</em:id> <em:name>userChromeJS</em:name> - <em:version>1.1</em:version> + <em:version>1.1.10070301</em:version> <em:description></em:description> <em:creator>alta88</em:creator> <em:contributor>zeniko (original author of userChrome.js)</em:contributor> <em:iconURL></em:iconURL> <em:homepageURL>http://userchromejs.mozdev.org/</em:homepageURL> <em:updateURL> https://www.mozdev.org/p/updates/userchromejs/userchromejs@mozdev.org/update.rdf </em:updateURL> <em:updateInfoURL> http://userchromejs.mozdev.org/updateInfo.xhtml </em:updateInfoURL> <em:targetApplication><!-- Firefox --> <Description> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:minVersion>3.0</em:minVersion> - <em:maxVersion>3.*</em:maxVersion> + <em:maxVersion>4.*</em:maxVersion> </Description> </em:targetApplication> <em:targetApplication><!-- Thunderbird --> <Description> <em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id> <em:minVersion>3.0b1</em:minVersion> <em:maxVersion>3.*</em:maxVersion>
Philip Chee

Posts: 6475Joined: March 1st, 2005, 3:03 pm
Posted July 13th, 2010, 1:21 pm
- Code: Select all
switch (aTopic) { case "app-startup": os.addObserver(this, "final-ui-startup", false); break; + case "profile-after-change": + os.addObserver(this, "final-ui-startup", false); + break;
Try this instead: - Code: Select all
switch (aTopic) { case "app-startup": + case "profile-after-change": os.addObserver(this, "final-ui-startup", false); break;
Phil
alta88
Posts: 1022Joined: January 28th, 2006, 3:08 pm
Posted July 22nd, 2010, 9:25 am
version 1.2 has been uploaded with Alice0775's Gecko 2.0 xpcom registration changes patch and Phil's tweak, it should auto update.
gialloporpora

Posts: 362Joined: October 24th, 2005, 12:44 pm
Posted July 28th, 2010, 5:00 am
Dear all, I hope this is the correct topic to ask my question. I have installed userChromeJS 1.2 (first I used userChrome.js 0.8) on Thunderbird 3.1.1, and this code doesn't works: UserChrome.js/Mail - MozillaZine Knowledge Base// make account and folder names available to userChrome.css with (document.getElementById("folderNameCell")) setAttribute("properties", getAttribute("properties") + " name-?folderTreeName")
The console said that folderNameCell is null. If I enable the same tweak on Mail-Tweak extension it works (the code is very similar). I think it must be specified the chrome path where executing the code: if (location == "chrome://…'){ … } but I don't know how to find che correct chrome url, somebody can help me? I have already tried to spy the Windows with DOM Inspector but I don't find it.
alta88
Posts: 1022Joined: January 28th, 2006, 3:08 pm
Posted July 28th, 2010, 5:54 pm
- Code: Select all
if (location == "chrome://messenger/content/messenger.xul") {}
Return to Extension/Theme Releases
Who is online
Users browsing this forum: No registered users and 2 guests
|