[Ext] userChromeJS 2.0 [2015-08-02]
-
- Posts: 1029
- Joined: January 28th, 2006, 3:08 pm
[Ext] userChromeJS 2.0 [2015-08-02]
userChromeJS has been released as an extension.
userChromeJS allows complete chrome customization when an extension is excessive.
userChromeJS is derived from the original userChrome.js by zeniko. An import function has been added to enable greater flexibility in absolute/relative file management, along with some overlay tweaks. Thanks to zeniko for the original idea; the bug to implement this functionality in core Mozilla is Bug 332529.
See the userChromeJS Home Page for details, release notes, download, and FAQ. Note that userChromeJS is meant to be used with Gecko 1.9.0 and higher applications (Firefox 3.0 and higher, Thunderbird 3.0 beta and higher, etc.).
userChromeJS allows complete chrome customization when an extension is excessive.
userChromeJS is derived from the original userChrome.js by zeniko. An import function has been added to enable greater flexibility in absolute/relative file management, along with some overlay tweaks. Thanks to zeniko for the original idea; the bug to implement this functionality in core Mozilla is Bug 332529.
See the userChromeJS Home Page for details, release notes, download, and FAQ. Note that userChromeJS is meant to be used with Gecko 1.9.0 and higher applications (Firefox 3.0 and higher, Thunderbird 3.0 beta and higher, etc.).
Last edited by alta88 on August 3rd, 2015, 12:31 pm, edited 6 times in total.
- pirlouy
- Posts: 232
- Joined: February 11th, 2005, 6:29 am
- Location: France
Re: [Ext] userChromeJS 1.0 [2008-12-22]
Great to see this extension updated. The new function to use .js files is great.
I just want to share this so useful script (by pile0nades) which allows to put statusbar in toolbar (or menubar)
I just want to share this so useful script (by pile0nades) which allows to put statusbar in toolbar (or menubar)
Code: Select all
var statusbar = document.getElementById("status-bar");
var menubar = document.getElementById("nav-bar");
menubar.appendChild(statusbar);
/* statusbar.setAttribute("style", "-moz-appearance: none;");*/
statusbar.setAttribute("flex", "1");
-
- Posts: 243
- Joined: November 9th, 2005, 7:31 pm
Re: [Ext] userChromeJS 1.0 [2008-12-22]
Hey this is excellent... really happy to see someone take up this extension and update it. It was disappointing when Zeniko stopped supporting it.
Anyways, are you planning to release it on AMO? That would be really good.
Anyways, are you planning to release it on AMO? That would be really good.
-
- Posts: 243
- Joined: November 9th, 2005, 7:31 pm
Re: [Ext] userChromeJS 1.0 [2008-12-22]
A couple older posts on userChrome.js where lot of useful scripts can be found:
viewtopic.php?t=397735
viewtopic.php?t=594331
viewtopic.php?t=397735
viewtopic.php?t=594331
- Alice0775
- Posts: 2819
- Joined: October 26th, 2007, 11:25 pm
- Location: OSAKA
Re: [Ext] userChromeJS 1.0 [2008-12-22]
The following patch(using observer) will fix the Bug330458.
Code: Select all
diff -b8 -u orig/content/userChromeJS.js new/content/userChromeJS.js
--- orig/content/userChromeJS.js 2008-12-20 17:46:04.000000000 +0900
+++ new/content/userChromeJS.js 2008-12-29 11:15:04.000000000 +0900
@@ -45,36 +45,16 @@
var Cr = Components.results;
if (typeof Cu == "undefined")
var Cu = Components.utils;
var userChrome = {
path: null,
dirToken: null,
- get loadOverlayDelay () {
- if (!this._loadOverlayDelay)
- this._loadOverlayDelay = 500;
- return this._loadOverlayDelay;
- },
-
- set loadOverlayDelay(delay) {
- this._loadOverlayDelay = delay;
- },
-
- get loadOverlayDelayIncr() {
- if (!this._loadOverlayDelayIncr)
- this._loadOverlayDelayIncr = 1600;
- return this._loadOverlayDelayIncr;
- },
-
- set loadOverlayDelayIncr(delay) {
- this._loadOverlayDelayIncr = delay;
- },
-
import: function(aPath, aRelDirToken) {
let file;
this.path = aPath;
this.dirToken = aRelDirToken;
if (aRelDirToken) {
// Relative file
let absDir = this.getAbsoluteFile(aRelDirToken);
@@ -92,18 +72,17 @@
if (!file)
return;
if (file.isFile()) {
if (/\.js$/i.test(file.leafName))
this.loadScript(file, aRelDirToken, null);
else if (/\.xul$/i.test(file.leafName)) {
let xul_files = [];
xul_files.push(file);
- this.loadOverlay(xul_files, this.dirToken, null, this.loadOverlayDelay);
-// this.loadOverlayDelay = this.loadOverlayDelay + this.loadOverlayDelayIncr;
+ this.loadOverlay(xul_files, this.dirToken, null);
}
else
this.log("File '" + this.path +
"' does not have a valid .js or .xul extension.", "import");
}
else if (file.isDirectory())
this.importFolder(file);
else
@@ -118,37 +97,24 @@
loadSubScript(userChrome.getURLSpecFromFile(aFile), null);
// log it
userChrome.log(aRelDirToken ? ("[" + aRelDirToken + "]/" +
(aFolder && aFolder != "*" ? aFolder + "/" : "") + aFile.leafName) :
aFile.path, "loadScript");
}, 0);
},
- // XXX: Due to bug 330458, an overlay must finish before another can be
- // called, otherwise neither are successful. Implementing an observer to
- // serialize is better left as a fix in the core bug. Here, settimout values
- // are set to minimize but there is no quarantee; overlay cdata (if any)
- // needs to consider overlay completions and logging does not strictly mean
- // an overlay has completed, rather that the overlay file has been invoked.
- loadOverlay: function(aFiles, aRelDirToken, aFolder, aDelay) {
-//userChrome.log(aDelay, "multiple import delay");
- // Increment multiple import delay
- this.loadOverlayDelay = this.loadOverlayDelay + this.loadOverlayDelayIncr;
- setTimeout(function() {
- if (aFiles.length > 0) {
-//userChrome.log(userChrome.loadOverlayDelay, "inter folder delay");
+ loadOverlay: function(aFiles, aRelDirToken, aFolder) {
+ aFiles.forEach(function(aFile){
// log it
userChrome.log(aRelDirToken ? ("[" + aRelDirToken + "]/" +
- (aFolder && aFolder != "*" ? aFolder + "/" : "") + aFiles[0].leafName) :
- aFiles[0].path, "loadOverlay");
- document.loadOverlay(userChrome.getURLSpecFromFile(aFiles.shift()), null);
- setTimeout(arguments.callee, userChrome.loadOverlayDelay);
- }
- }, aDelay);
+ (aFolder && aFolder != "*" ? aFolder + "/" : "") + aFile.leafName) :
+ aFile.path, "loadOverlay");
+ document.loadOverlay(userChrome.getURLSpecFromFile(aFile), null);
+ });
},
// Include all files ending in .js and .xul from passed folder
importFolder: function(aFolder) {
let files = aFolder.directoryEntries.QueryInterface(Ci.nsISimpleEnumerator);
let xul_files = [];
while (files.hasMoreElements()) {
@@ -225,8 +191,85 @@
},
get date() {
let date = new Date();
return date.toLocaleFormat(this.dateFormat);
}
};
+
+//Bug 330458 Cannot dynamically load an overlay using document.loadOverlay
+//until a previous overlay is completely loaded
+var fixbug330458 = {
+ overlayqueue:0,
+ overlayUrl:[],
+ loadOverlay: function(aUrl, aObserver){
+ fixbug330458.overlayUrl.push([aUrl, aObserver]);
+ if (!fixbug330458.overlayqueue)
+ fixbug330458.load(++fixbug330458.overlayqueue);
+ },
+
+ load: function (){
+ if(!fixbug330458.overlayUrl.length)
+ return --fixbug330458.overlayqueue;
+ var [aUrl, aObserver] = this.overlayUrl.shift();
+ if (!aObserver)
+ aObserver = fixbug330458.observer;
+ else {
+ var func = aObserver.observe.toString();
+ func = func.replace(
+ /{/,
+ <><![CDATA[
+ $&
+ if (arguments[1] == 'xul-overlay-merged') {
+ fixbug330458.load();
+ }
+ ]]></>
+ );
+ try {
+ aObserver.observe = eval("atmp = " + func);
+ } catch(ex) {
+ fixbug330458.error(aUrl, ex);
+ }
+ }
+ var original_loadOverlay = Components.lookupMethod(document, 'loadOverlay');
+ try {
+ original_loadOverlay(aUrl, aObserver);
+ } catch(ex) {
+ fixbug330458.error(aUrl, ex);
+ }
+ return 0;
+ },
+
+ observer: {
+ observe : function (subject, topic, data) {
+ if (topic == 'xul-overlay-merged') {
+ fixbug330458.load();
+ }
+ },
+ QueryInterface: function(aIID){
+ if(!aIID.equals(Components.interfaces.nsISupports)
+ && !aIID.equals(Components.interfaces.nsIObserver))
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ return this
+ }
+ },
+
+ error: function(aMsg, err){
+ const Cc = Components.classes;
+ const Ci = Components.interfaces;
+ const CONSOLE_SERVICE = Cc['@mozilla.org/consoleservice;1'].getService(Ci.nsIConsoleService);
+ var error = Cc['@mozilla.org/scripterror;1'].createInstance(Ci.nsIScriptError);
+ if (typeof(err) == 'object')
+ error.init(aMsg + '\n' + err.name + ' : ' + err.message,
+ err.fileName || null,
+ null,
+ err.lineNumber,
+ null,
+ 2,
+ err.name);
+ else
+ error.init(aMsg + '\n' + err + '\n', null, null, null, null, 2, null);
+ CONSOLE_SERVICE.logMessage(error);
+ }
+}
+document.loadOverlay = fixbug330458.loadOverlay;
-
- Posts: 1029
- Joined: January 28th, 2006, 3:08 pm
Re: [Ext] userChromeJS 1.0 [2008-12-22]
aronin wrote:Anyways, are you planning to release it on AMO? That would be really good.
no.
-
- Posts: 1029
- Joined: January 28th, 2006, 3:08 pm
Re: [Ext] userChromeJS 1.0 [2008-12-22]
Alice0775 wrote:The following patch(using observer) will fix the Bug330458
Alice0775, thanks for the patch. i may consider implementing it, but there seems to be some movement in the Fx bug, and it would be cleaner if it were fixed there.
-
- Posts: 243
- Joined: November 9th, 2005, 7:31 pm
Re: [Ext] userChromeJS 1.0 [2008-12-22]
From Zeniko - in another thread... code to open New Tab from URL/Location Bar. The earlier code was broken in Fx3.1.
Code: Select all
eval("gURLBar.handleCommand = " + gURLBar.handleCommand.toString().replace("if (aTriggeringEvent instanceof MouseEvent)", "if ((gBrowser.currentURI.spec != 'about:blank' || gBrowser.webProgress.isLoadingDocument) && (!aTriggeringEvent || !aTriggeringEvent.ctrlKey && !aTriggeringEvent.shiftKey && !aTriggeringEvent.altKey)) gBrowser.selectedTab = gBrowser.addTab(); $&"));
-
- Posts: 2
- Joined: January 12th, 2009, 9:57 am
Re: [Ext] userChromeJS 1.0 [2008-12-22]
The BookmarksConfirmation.uc.js, which confirms before deleting bookmarks, is "Not compatibled with Firefox 3" http://www.xuldev.org/misc/script/Bookm ... tion.uc.js - does anyone know an up-to-date script like this?
Thanks
Thanks
- Alice0775
- Posts: 2819
- Joined: October 26th, 2007, 11:25 pm
- Location: OSAKA
Re: [Ext] userChromeJS 1.0 [2008-12-22]
Marx_Brother wrote:The BookmarksConfirmation.uc.js, which confirms before deleting bookmarks, is "Not compatibled with Firefox 3" http://www.xuldev.org/misc/script/Bookm ... tion.uc.js - does anyone know an up-to-date script like this?
Thanks
Code: Select all
// ==UserScript==
// @name Bookmarks Confirmation
// @namespace http://www.xuldev.org/
// @description Confirms before deleting or sorting bookmarks.
// @include main
// @include chrome://browser/content/bookmarks/bookmarksPanel.xul
// @include chrome://browser/content/places/places.xul
// @include chrome://libraryinsidebar/content/sidebarPlacesOverlay.xul
// @author Gomita
// @modifier Alice0775
// @version 2009/01/03 23:00 Fx 3.0, 3.1, 3.2a1pre
// @version 1.0.20080201
// @homepage http://www.xuldev.org/misc/ucjs.php
// @note Not compatibled with Firefox 2
// @note userChrome.bookmarksConfirmation : [true] false
// ==/UserScript==
(function() {
if ("PlacesController" in window == false)
// [Firefox3a]
return;
var func;
func = PlacesController.prototype._removeRowsFromBookmarks.toString();
func = func.replace(
"var ranges = this._view.getRemovableSelectionRanges();",
<><![CDATA[
$&
try {
this._view.hidePopup();
} catch(ex) {}
try {
var flg = gPrefService.getBoolPref('userChrome.bookmarksConfirmation');
} catch(ex){
var flg = true;
}
if (flg &&
!window.confirm('Are you sure you wish to delete bookmarks?'))
return;
]]></>
);
eval("PlacesController.prototype._removeRowsFromBookmarks = " + func);
func = PlacesController.prototype.sortFolderByName.toString();
func = func.replace(
"var itemId = PlacesUtils.getConcreteItemId(this._view.selectedNode);",
<><![CDATA[
$&
try {
this._view.hidePopup();
} catch(ex) {}
try {
var flg = gPrefService.getBoolPref('userChrome.bookmarksConfirmation');
} catch(ex){
var flg = true;
}
if (flg &&
!window.confirm('Are you sure you wish to sort bookmarks?'))
return;
]]></>
);
eval("PlacesController.prototype.sortFolderByName = " + func);
}());
It works with Sub-Script/Overlay Loader v3.0.20mod and more which is available in Sub-Script/Overlay Loader v3.0.20mod.
Last edited by Alice0775 on May 22nd, 2009, 8:56 pm, edited 1 time in total.
- pirlouy
- Posts: 232
- Joined: February 11th, 2005, 6:29 am
- Location: France
Re: [Ext] userChromeJS 1.0 [2008-12-22]
Maybe Alice or someone else knows what I have to change to this script in order to make it compatible with Firefox 3.1
I've seen FireGestures uses this function which works:
I suppose the script has to replace Firefox default function, but I don't know how to. :/
Code: Select all
/* select left tab when closing tab */
eval("gBrowser.removeTab = " + gBrowser.removeTab.toString().
replace("index == l - 1", "index > 0"));
I've seen FireGestures uses this function which works:
Code: Select all
var tab = gBrowser.mCurrentTab;
if(tab.previousSibling)
gBrowser.mTabContainer.selectedIndex--;
gBrowser.removeTab(tab);
I suppose the script has to replace Firefox default function, but I don't know how to. :/
- Alice0775
- Posts: 2819
- Joined: October 26th, 2007, 11:25 pm
- Location: OSAKA
Re: [Ext] userChromeJS 1.0 [2008-12-22]
Code: Select all
/* select left tab when closing tab */
gBrowser.addEventListener("TabClose", function OTN_onTabClose(aEvent) {
if(aEvent.originalTarget != gBrowser.selectedTab)
return;
if(aEvent.originalTarget._tPos > 0)
gBrowser.mTabContainer.advanceSelectedTab(-1, false);
}, false);
- pirlouy
- Posts: 232
- Joined: February 11th, 2005, 6:29 am
- Location: France
Re: [Ext] userChromeJS 1.0 [2008-12-22]
Thank you very much.
So this is another way to achieve it...
So this is another way to achieve it...
-
- Posts: 2
- Joined: January 12th, 2009, 9:57 am
Re: [Ext] userChromeJS 1.0 [2008-12-22]
@Alice0775
Thanks for your modified code Bookmarks Confirmation, but it works only in the bookmarks-menu and in the personal bookmarks-toolbar of my Firefox 3.0.5 German, not in the sidebar!
Thanks for your modified code Bookmarks Confirmation, but it works only in the bookmarks-menu and in the personal bookmarks-toolbar of my Firefox 3.0.5 German, not in the sidebar!
- Alice0775
- Posts: 2819
- Joined: October 26th, 2007, 11:25 pm
- Location: OSAKA
Re: [Ext] userChromeJS 1.0 [2008-12-22]
Marx_Brother wrote:@Alice0775
Thanks for your modified code Bookmarks Confirmation, but it works only in the bookmarks-menu and in the personal bookmarks-toolbar of my Firefox 3.0.5 German, not in the sidebar!
It works in the sidebar too.
You should use "Sub-Script/Overlay Loader v3.0" or the compatible.