[Ext] userChrome.js

Announce and Discuss the Latest Theme and Extension Releases.
Locked
Webb
Posts: 698
Joined: July 18th, 2003, 9:49 am

Post by Webb »

This looks like the extension I'm looking for because css can't do this. I'm a complete js newbie so can someone tell me if can do this and how?

I'm using the full screen extension so I have no Windows title bar and no Windows min/restore/maximize buttons.

Fx puts its min/restore/max buttons (#windows-controls) on the navigation bar (as shown in the screenshot) but I'd like top move them up to the menu bar, where the exit button (provided by an extension) is.

Can js do this and if so how? Thanks.

Image
pile0nades
Posts: 756
Joined: May 15th, 2005, 2:31 am

Post by pile0nades »

This is weird. When I use this simple code:

Code: Select all

(function(){
  var toolbox = document.getElementById("navigator-toolbox");
  var browser = document.getElementById("browser-stack");
  toolbox.parentNode.insertBefore(toolbox, browser.nextSibling);
})();


which moves my menu and toolbars to the bottom, the nav bar shows twice on the same line! Both of them work fine, apparently, but I don't know how that could happen. Screenshot:
Image

Looking in the DOMi, it seems the toolbar elements are cloned. Any ideas?
Linkify bug numbers - test: bug 258287
pile0nades
Posts: 756
Joined: May 15th, 2005, 2:31 am

Post by pile0nades »

Webb wrote:This looks like the extension I'm looking for because css can't do this. I'm a complete js newbie so can someone tell me if can do this and how?

I'm using the full screen extension so I have no Windows title bar and no Windows min/restore/maximize buttons.

Fx puts its min/restore/max buttons (#windows-controls) on the navigation bar (as shown in the screenshot) but I'd like top move them up to the menu bar, where the exit button (provided by an extension) is.

Can js do this and if so how? Thanks.

Image


Code: Select all

document.getElementById("toolbar-menubar").appendChild(document.getElementById("window-controls"));


Edit: fixed typo :)
Last edited by pile0nades on February 4th, 2007, 8:20 pm, edited 1 time in total.
Linkify bug numbers - test: bug 258287
User avatar
Grist
Posts: 836
Joined: January 27th, 2006, 9:20 pm

Post by Grist »

pile0nades wrote:This is weird. When I use this simple code:

Code: Select all

(function(){
  var toolbox = document.getElementById("navigator-toolbox");
  var browser = document.getElementById("browser-stack");
  toolbox.parentNode.insertBefore(toolbox, browser.nextSibling);
})();


which moves my menu and toolbars to the bottom, the nav bar shows twice on the same line! Both of them work fine, apparently, but I don't know how that could happen. Screenshot:
Image

Looking in the DOMi, it seems the toolbar elements are cloned. Any ideas?

Weird. I tried it and I'm not getting duplicate elements. You might see if this makes a difference:

Code: Select all

(function() {
  var toolbox = document.getElementById("navigator-toolbox");
  var browser = document.getElementById("browser-stack");
  browser.parentNode.insertBefore(toolbox, browser.nextSibling);
})();
pile0nades
Posts: 756
Joined: May 15th, 2005, 2:31 am

Post by pile0nades »

I found it was because of All in One Sidebar. With it disabled, it works as expected.
Linkify bug numbers - test: bug 258287
Webb
Posts: 698
Joined: July 18th, 2003, 9:49 am

Post by Webb »

Thank you, pile0nades.

That didn't work but "window-controls" does.
Old Greg S
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by Old Greg S »

Sometimes when Fx loads, some of the xul/js toolbarbuttons,statusbarpanels etc.. will not load. I have to select File + New Window for them to load. Is this to be expected at times? I've also noticed that extensions such as Organize Statusbar and Menu Edit can't retain the order of something I've added when said extensions are used to organize these added items.
pile0nades
Posts: 756
Joined: May 15th, 2005, 2:31 am

Post by pile0nades »

Greg S wrote:Sometimes when Fx loads, some of the xul/js toolbarbuttons,statusbarpanels etc.. will not load. I have to select File + New Window for them to load. Is this to be expected at times? I've also noticed that extensions such as Organize Statusbar and Menu Edit can't retain the order of something I've added when said extensions are used to organize these added items.


pile0nades wrote:
zeniko wrote:Update: I've additionally updated the Sub-Script Loader snippet to automatically include all files ending in .uc.xul as well. It now completely replaces the original userChrome.xul snippet.


That code is affected by bug 355038. It breaks if document.loadOverlay is called more than once in succession; the XUL files won't load. That's why my code had a setTimeout calling a seperate function to load the XULs as a workaround.

<a href="data:text/javascript;charset=utf-8;base64,LyogOjo6Ojo6OjogU3ViLVhVTC9TY3JpcHQgTG9hZGVyIDo6Ojo6Ojo6Ojo6Ojo6OiAqLw0KDQovLyBhdXRvbWF0aWNhbGx5IGluY2x1ZGVzIGFsbCBmaWxlcyBlbmRpbmcgaW4gLnVjLnh1bCBhb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bGwpOw0KICAgIH0NCiAgICBlbHNlIGlmKC9cLnVjXC5qcyQvaS50ZXN0KGZpbGUubGVhZk5hbWUpKSB7DQogICAgICBDb21wb25lbnRzLmNsYXNzZXNbIkBtb3ppbGxhLm9yZy9tb3ovanNzdWJzY3JpcHQtbG9hZGVyOzEiXS5nZXRTZXJ2aWNlKENvbXBvbmVudHMuaW50ZXJmYWNlcy5tb3pJSlNTdWJTY3JpcHRMb2FkZXIpLmxvYWRTdWJTY3JpcHQoQ29tcG9uZW50cy5jbGFzc2VzWyJAbW96aWxsYS5vcmcvbmV0d29yay9pby1zZXJ2aWNlOzEiXS5nZXRTZXJ2aWNlKENvbXBvbmVudHMuaW50ZXJmYWNlcy5uc0lJT1NlcnZpY2UpLmdldFByb3RvY29sSGFuZGxlcigiZmlsZSIpLlF1ZXJ5SW50ZXJmYWNlKENvbXBvbmVudHMuaW50ZXJmYWNlcy5uc0lGaWxlUHJvdG9jb2xIYW5kbGVyKS5nZXRVUkxTcGVjRnJvbUZpbGUoZmlsZSkpOw0KICAgIH0NCiAgICBpZihmaWxlcy5oYXNNb3JlRWxlbWVudHMoKSkgc2V0VGltZW91dChsb2FkWFVMb3JKUywgMCwgZmlsZXMpOw0KICB9DQp9KSgpOw%3D%3D">This code</a> fixes it.


Try this version of the sub-script loader and see if it works.
Linkify bug numbers - test: bug 258287
Old Greg S
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by Old Greg S »

pile0nades wrote:
Greg S wrote:Sometimes when Fx loads, some of the xul/js toolbarbuttons,statusbarpanels etc.. will not load. I have to select File + New Window for them to load. Is this to be expected at times? I've also noticed that extensions such as Organize Statusbar and Menu Edit can't retain the order of something I've added when said extensions are used to organize these added items.


pile0nades wrote:
zeniko wrote:Update: I've additionally updated the Sub-Script Loader snippet to automatically include all files ending in .uc.xul as well. It now completely replaces the original userChrome.xul snippet.


That code is affected by bug 355038. It breaks if document.loadOverlay is called more than once in succession; the XUL files won't load. That's why my code had a setTimeout calling a seperate function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VudHMuaW50ZXJmYWNlcy5uc0lJT1NlcnZpY2UpLmdldFByb3RvY29sSGFuZGxlcigiZmlsZSIpLlF1ZXJ5SW50ZXJmYWNlKENvbXBvbmVudHMuaW50ZXJmYWNlcy5uc0lGaWxlUHJvdG9jb2xIYW5kbGVyKS5nZXRVUkxTcGVjRnJvbUZpbGUoZmlsZSksIG51bGwpOw0KICAgIH0NCiAgICBlbHNlIGlmKC9cLnVjXC5qcyQvaS50ZXN0KGZpbGUubGVhZk5hbWUpKSB7DQogICAgICBDb21wb25lbnRzLmNsYXNzZXNbIkBtb3ppbGxhLm9yZy9tb3ovanNzdWJzY3JpcHQtbG9hZGVyOzEiXS5nZXRTZXJ2aWNlKENvbXBvbmVudHMuaW50ZXJmYWNlcy5tb3pJSlNTdWJTY3JpcHRMb2FkZXIpLmxvYWRTdWJTY3JpcHQoQ29tcG9uZW50cy5jbGFzc2VzWyJAbW96aWxsYS5vcmcvbmV0d29yay9pby1zZXJ2aWNlOzEiXS5nZXRTZXJ2aWNlKENvbXBvbmVudHMuaW50ZXJmYWNlcy5uc0lJT1NlcnZpY2UpLmdldFByb3RvY29sSGFuZGxlcigiZmlsZSIpLlF1ZXJ5SW50ZXJmYWNlKENvbXBvbmVudHMuaW50ZXJmYWNlcy5uc0lGaWxlUHJvdG9jb2xIYW5kbGVyKS5nZXRVUkxTcGVjRnJvbUZpbGUoZmlsZSkpOw0KICAgIH0NCiAgICBpZihmaWxlcy5oYXNNb3JlRWxlbWVudHMoKSkgc2V0VGltZW91dChsb2FkWFVMb3JKUywgMCwgZmlsZXMpOw0KICB9DQp9KSgpOw%3D%3D">This code</a> fixes it.


Try this version of the sub-script loader and see if it works.


Thanks, so I replace my subscript loader code, correct?
old nicholas.alipaz
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by old nicholas.alipaz »

Could anyone figure out the script to modify the back part of the "Unified back/forward" button from the "Unified back/forward button extension" so that right-click goes forward?
Old Greg S
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by Old Greg S »

pile0nades wrote:Try this version of the sub-script loader and see if it works.

Dang pile0nades, I must have some serious .xul code problems or it could be the obvious, I don't know exactly how to use/amend the sub-script because none of my xul is working.

Instructions please!,lol
pile0nades
Posts: 756
Joined: May 15th, 2005, 2:31 am

Post by pile0nades »

OK, can you post your userChrome.js file here?
Linkify bug numbers - test: bug 258287
Old Greg S
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by Old Greg S »

pile0nades wrote:OK, can you post your userChrome.js file here?


This is what I have before using what you've posted

Code: Select all

/* :::::::: userChrome.xul ::::::::::::::: */

(function() {
   var userChrome_xul = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("UChrm", Components.interfaces.nsILocalFile);
   userChrome_xul.append("userChrome.xul");
   
   if (userChrome_xul.exists())
   {
      var fileURL = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler).getURLSpecFromFile(userChrome_xul);
      document.loadOverlay(fileURL, null);
   }
})();


/* :::::::: Sub-Script Loader ::::::::::::::: */

// automatically includes all files ending in .uc.js from the profile's chrome folder

(function() {
   var chromeDir = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("UChrm", Components.interfaces.nsILocalFile);
   var files = chromeDir.directoryEntries.QueryInterface(Components.interfaces.nsISimpleEnumerator);
   
   while (files.hasMoreElements())
   {
      var file = files.getNext().QueryInterface(Components.interfaces.nsIFile);
      if (/\.uc\.js$/i.test(file.leafName))
      {
         setTimeout(function(aFile) {
            Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader).loadSubScript(Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler).getURLSpecFromFile(aFile));
         }, 0, file);
      }
   }
})();
pile0nades
Posts: 756
Joined: May 15th, 2005, 2:31 am

Post by pile0nades »

Use this as your userChrome.js file:

Code: Select all

/* :::::::: Sub-XUL/Script Loader ::::::::::::::: */

// automatically includes all files ending in .uc.xul and .uc.js from the profile's chrome folder

(function() {
  var chromeDir = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("UChrm", Components.interfaces.nsILocalFile);
  var files = chromeDir.directoryEntries.QueryInterface(Components.interfaces.nsISimpleEnumerator);
  if(files.hasMoreElements()) loadXULorJS(files);

  function loadXULorJS(files) {
    var file = files.getNext().QueryInterface(Components.interfaces.nsIFile);
    if (/(^userChrome|\.uc)\.xul$/i.test(file.leafName)) {
      document.loadOverlay(Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler).getURLSpecFromFile(file), null);
    }
    else if(/\.uc\.js$/i.test(file.leafName)) {
      Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader).loadSubScript(Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler).getURLSpecFromFile(file));
    }
    if(files.hasMoreElements()) setTimeout(loadXULorJS, 0, files);
  }
})();


I removed the top code because this sub-script loader will load a userChrome.xul file too, so with the top code, the file would have been loaded twice.
Last edited by pile0nades on February 9th, 2007, 10:54 am, edited 1 time in total.
Linkify bug numbers - test: bug 258287
Miccovin
Posts: 51
Joined: February 9th, 2007, 12:44 am

Post by Miccovin »

hi, can you take a look at this problem, please? It still exists :/

userChrome.js: Opening download manager in tab doesn't work
Locked