MozillaZine

[Ext] userChrome.js

Announce and Discuss the Latest Theme and Extension Releases.
pile0nades
 
Posts: 756
Joined: May 15th, 2005, 2:31 am

Post Posted May 25th, 2006, 8:47 am

Zoolcar9, that worked perfectly thanks! Edit:

This is for userChrome.js. It moves the Find Bar to the top just under the tabs, and moves the close button to the right side.

<a href="data:text/javascript;charset=utf-8;base64,LyogRmluZCBiYXIgb24gdG9wICovDQooZnVuY3Rpb24gKCkgew0KICAvLyBtb3ZlIGZpbmQgYmFyIHRvIHRoZSB0b3ANCiAgLy8gdGhhbmtzIHRvIFpvb2xjYXI5IGZvciB0aGlzIGNvZGUNCiAgdmFyIGZpbmRiYXIgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgnRmluZFRvb2xiYXInKTsNCiAgdmFyIHRhYmJyb3dzZXIgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgnY29udGVudCcpOw0KICB2YXIgdGFicGFuZWxzID0gdGFiYnJvd3Nlci5tUGFuZWxDb250YWluZXI7DQogIHRhYnBhbmVscy5wYXJlbnROb2RlLmluc2VydEJlZm9yZShmaW5kYmFyLCB0YWJwYW5lbHMpOw0KICANCiAgLy8gbW92ZSB0aGUgdG9wIGJvcmRlciB0byB0aGUgYm90dG9tDQogIGZpbmRiYXIuc2V0QXR0cmlidXRlKCJzdHlsZSIsICItbW96LWJvcmRlci1ib3R0b20tY29sb3JzOiBub25lOyIpOyAvLyB0aGFua3MgYWdhaW4gWm9vbGNhcjkhDQogIGZpbmRiYXIuc3R5bGUuYm9yZGVyVG9wID0gIjFweCBzb2xpZCI7DQogIGZpbmRiYXIuc3R5bGUuYm9yZGVyQm90dG9tID0gIjFweCBzb2xpZCI7DQoNCiAgLy8gbW92ZSBjbG9zZSBidXR0b24gcmlnaHQgIA0KICBmaW5kYmFyLmFwcGVuZENoaWxkKGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInRvb2xiYXJzcHJpbmciKSk7DQogIGZpbmRiYXIuYXBwZW5kQ2hpbGQoZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoImZpbmQtY2xvc2VidXR0b24iKSk7DQogIA0KfSkoKTs%3D">findbarontop.uc.js</a>

Edit: fix bottom border.
Last edited by pile0nades on May 25th, 2006, 6:16 pm, edited 2 times in total.
Linkify bug numbers - test: bug 258287

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted May 25th, 2006, 10:28 am


For bottom border

Code: Select all
findbar.setAttribute("style", "-moz-border-bottom-colors: none;");

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

paulfox
 
Posts: 1510
Joined: May 8th, 2004, 1:38 pm

Post Posted May 25th, 2006, 11:07 am

I'm fuzzy on incorporating "XUL." What are steps required ot make userChrome/js see "userChromeXUL," or do I just create a separate named-extension file for it?

http://forums.mozillazine.org/viewtopic.php?t=419965

Apparently I'm not alone; just want to get the i's dotted and t's crossed before I "go nuts" with this stuff!! Cheers/thanks in advance
PentiumIII/W2K, Toshiba AMD laptop/Vista. FX 3 on both.

dougeeebear

User avatar
 
Posts: 548
Joined: September 15th, 2005, 4:17 pm

Post Posted May 25th, 2006, 11:44 am

Zoolcar9,
The toolbar button works like a charm.
I changed <code>insertbefore="menubar-items"</code> to <code>insertbefore="throbber-box"</code> to place it on the other end.
Thanks for the help.

JNewbry

User avatar
 
Posts: 321
Joined: April 9th, 2005, 3:56 am
Location: Dallas,TX

Post Posted May 25th, 2006, 11:47 am

paulfox:
Make sure this is in userChrome.js
<a href="data:text/javascript,%2F*%20%3A%3A%3A%3A%3A%3A%3A%3A%20userChrome.xul%20%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%20*%2F%0A%0A(function()%20%7B%0A%09var%20userChrome_xul%20%3D%20Components.classes%5B%22%40mozilla.org%2Ffile%2Fdirectory_service%3B1%22%5D.getService(Components.interfaces.nsIProperties).get(%22UChrm%22%2C%20Components.interfaces.nsILocalFile)%3B%0A%09userChrome_xul.append(%22userChrome.xul%22)%3B%0A%09%0A%09if%20(userChrome_xul.exists())%0A%09%7B%0A%09%09var%20fileURL%20%3D%20Components.classes%5B%22%40mozilla.org%2Fnetwork%2Fio-service%3B1%22%5D.getService(Components.interfaces.nsIIOService).getProtocolHandler(%22file%22).QueryInterface(Components.interfaces.nsIFileProtocolHandler).getURLSpecFromFile(userChrome_xul)%3B%0A%09%09document.loadOverlay(fileURL%2C%20null)%3B%0A%09%7D%0A%7D)()%3B%0A">userChrome.xul</a>

Then save the below as userChrome.xul
Code: Select all
<!-- Insert a line in this format for EACH custom overlay -->
<?xul-overlay href="optional-path-to-custom-overlay/name-of-Overlay1.xul"?>
<?xul-overlay href="optional-path-to-custom-overlay/name-of-Overlay2.xul"?>

<overlay id="pick-a-name-you-like"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
</overlay>

Think of Overlay 1 & 2...etc as you would @import in userChrome.css.
Make sense?
<a href="http://webdesigns.ms11.net/chromeditp.html" target="_blank">ChromEdit Plus</a> | <a href="http://webdesigns.ms11.net/winstripethemes.html" target="_blank">Firefox Themes</a>

dougeeebear

User avatar
 
Posts: 548
Joined: September 15th, 2005, 4:17 pm

Post Posted May 25th, 2006, 12:05 pm

@JNewbry:
I'm impressed with your ChromeEdit Plus SE extension.
With all the sub-files now being used with userChrome.css, userChrome.js (uc.js) and userChrome.xul, I think a dropdown menu next to each tab that would automatically detect and display a list of all files available in that tab's catagory would be a big help.
Then you could scroll down the list and edit a selected filename.
That would give a nice UI for all those files.
As it is, you have to open the chrome folder and edit all the sub-files manually.

Do you think this is something that would be doable?
Thanks, Doug

JNewbry

User avatar
 
Posts: 321
Joined: April 9th, 2005, 3:56 am
Location: Dallas,TX

Post Posted May 25th, 2006, 1:19 pm

dougeeebear.... Thanks! Glad your finding some use for the SE "branch"

You read my mind... I've been thinking about accessing the other files.
Give me a little time to try some hacks & see what works best.
Later, Jim
<a href="http://webdesigns.ms11.net/chromeditp.html" target="_blank">ChromEdit Plus</a> | <a href="http://webdesigns.ms11.net/winstripethemes.html" target="_blank">Firefox Themes</a>

dougeeebear

User avatar
 
Posts: 548
Joined: September 15th, 2005, 4:17 pm

Post Posted May 25th, 2006, 1:26 pm

JNewbry wrote:dougeeebear.... Thanks! Glad your finding some use for the SE "branch"

You read my mind... I've been thinking about accessing the other files.
Give me a little time to try some hacks & see what works best.
Later, Jim

Sounds great!

Old Greg S
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted May 25th, 2006, 5:03 pm

pile0nades wrote:
and moves the close button to the right side.


Speaking of find close button on the right, I'm wanting to add this to the view source window as well. Is this possible? I've tried with no joy so far.

paulfox
 
Posts: 1510
Joined: May 8th, 2004, 1:38 pm

Post Posted May 25th, 2006, 5:40 pm

@JNewbry: Thanks. Got it all except for last line "Think of overlay 1&2." Snippet is in userChrome.js, your other snippet "starts" XUL. OK. Tried placing userChrome.xul in "chrome" folder and trying the page 8-of this thread- "Manage bookkmarks thing," no workie. Then moved it to plain profile folder. No workie.
I'll figure it out.

Great links by the way in your sig - you've got some mighty cool stuff!! Thank you for your help.
PentiumIII/W2K, Toshiba AMD laptop/Vista. FX 3 on both.

dougeeebear

User avatar
 
Posts: 548
Joined: September 15th, 2005, 4:17 pm

Post Posted May 25th, 2006, 6:31 pm

@paulfox:
First of all, you need to enter the snippet posted above that containes /* :::::::: userChrome.xul ::::::::::::::: */ in your userChrome.js.
This enables the userChrome.xul file itself (plus enables the local xul overlays in general).
Then in turn, userChrome.xul enables all the xul file names that are listed in it.

Now, if you want to enable an xul file you need to do this:
First, create a userChrome.xul file in your chrome folder.

Then if for example your xul file name is "ManageBookmarkFolders.xul", your userChrome.xul file should look like this:
Code: Select all
<?xul-overlay href="ManageBookmarkFolders.xul"?>


<!-- do not enter anything below here -->
<overlay id="my-custom-xul-overlay-files"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
</overlay>

This will enable the "ManageBookmarkFolders.xul" file.
Then for each additional xul file you create, add another line below the first one to enable it.
All these xul files go in the chrome folder.
Hope this helps :)
Doug
Last edited by dougeeebear on May 25th, 2006, 6:57 pm, edited 1 time in total.

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

Post Posted May 25th, 2006, 6:57 pm

@Greg S,

You probably need to get the script to run in the view source window (chrome://global/content/viewSource.xul), but once that is done, this code should work:
Code: Select all
  var tabbrowser = document.getElementById('appcontent');
  var findbar = document.getElementById('FindToolbar');
  var browser = document.getElementById("content");
  tabbrowser.insertBefore(findbar, browser);
 
  // move the top border to the bottom
  findbar.setAttribute("style", "-moz-border-bottom-colors: none; border-top: 1px solid; border-bottom: 1px solid;"); // thanks again Zoolcar9!

  // move close button right 
  findbar.appendChild(document.createElement("toolbarspring"));
  findbar.appendChild(document.getElementById("find-closebutton"));
Linkify bug numbers - test: bug 258287

Old Ausdilecce
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted May 25th, 2006, 7:34 pm

I am absolutely loving this ability...

dougeeebear wrote:Since there has been some discussion (and a snippet) regarding userChrome.xul in this thread, I thought this might be an appropriate place to ask this question...

zeniko pointed me to information on changing confirmation dialog button names using confirmEx.
Now I am trying to change the OK and Cancel button names in a prompt dialog, but I can't seem to find a way to do it with just javascript.

I was thinking maybe I could do it with userChrome.xul (maybe in combination with userChrome.js).
I am still trying to figure out and understand the entries in userChrome.xul and an overlay.xul as shown by AnonEmoose.
I think if I was able to understand this a little more, that I could do it.
Any info/help on this would really be appreciated.


Here is a basic code snippet that will change the label "OK" to "NOT OK" in all prompt windows that use commonDialog.xul *only using JS*

<a href="data:application/x-javascript;charset=utf-8,var%20changePromptText%20%3D%20%7B%0D%0A%20%20%20%20logMsg%3A%20function(msg)%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20Components.classes%5B%22%40mozilla.org%2Fconsoleservice%3B1%22%5D.%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20getService(Components.interfaces.nsIConsoleService).logStringMessage(msg)%3B%0D%0A%20%20%20%20%7D%2C%0D%0A%20%20%20%20%0D%0A%20%20%20%20windowListener%3A%20%7B%0D%0A%20%20%20%20%20%20%20%20onCloseWindow%3A%20function(aWindow)%20%7B%20%7D%2C%0D%0A%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20onOpenWindow%3A%20function(aWindow)%20%7B%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20setTimeout(changePromptText.checkWindow%2C%20100%2C%20aWindow%2C%200)%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20changePromptText.logMsg(%22new%20Window%22)%3B%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20onWindowTitleChange%3A%20function(aWindow%2C%20newTitle)%20%7B%0D%0A%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%7D%2C%0D%0A%20%20%20%20%0D%0A%20%20%20%20checkWindow%3A%20function(aWindow%2Citer)%20%7B%0D%0A%20%20%20%20%20%20%20%20try%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20ddoc%20%3D%20aWindow.docShell.contentViewer.DOMDocument%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20href%20%3D%20ddoc.defaultView.document.location.href%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(href.indexOf('commonDialog.xu')%20!%3D%20-1)%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20got%20some%20kind%20of%20confirm%20box%2C%20change%20that%20text%20!%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20elements%20%3D%20ddoc.getElementById(%22commonDialog%22)._buttons%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20(var%20i%20in%20elements)%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(elements%5Bi%5D.label%20%3D%3D%20%22OK%22%20)%20elements%5Bi%5D.label%20%3D%20%22NOT%20OK%22%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%7D%20catch(e)%20%7B%7D%0D%0A%20%20%20%20%7D%2C%0D%0A%20%20%20%20%0D%0A%20%20%20%20killListener%3A%20function()%20%7B%0D%0A%20%20%20%20%20%20%20%20try%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20Components.classes%5B'%40mozilla.org%2Fappshell%2Fwindow-mediator%3B1'%5D.%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20getService(Components.interfaces.nsIWindowMediator).%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20removeListener(changePromptText.windowListener)%3B%0D%0A%20%20%20%20%20%20%20%20%7D%20catch(e)%20%7B%7D%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A%0D%0AComponents.classes%5B'%40mozilla.org%2Fappshell%2Fwindow-mediator%3B1'%5D.%0D%0A%20%20%20%20getService(Components.interfaces.nsIWindowMediator).%0D%0A%20%20%20%20addListener(changePromptText.windowListener)%3B%0D%0A%0D%0Awindow.addEventListener(%22unload%22%2C%20changePromptText.killListener%2C%20false)%3B%0D%0A">Source</a>

it is NOT localized (but can be, easily )

EDIT: Some of my extensions use this implementation to automatically respond to pesky alert and prompt windows
..like, in TB, automatically compacting folders and automatically clicking OK on the connection issues alerts

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

Post Posted May 25th, 2006, 7:59 pm

This is for Greasemonkey. On hixie's data uri kitchen, this script changes the mime type to text/javascript and checks the base64 checkbox, and blanks the textbox and focuses it automatically. This isn't really related to userChrome.js but makes it a bit faster to make data uris to post here.

<a href="data:text/javascript;charset=utf-8;base64,Ly8gPT1Vc2VyU2NyaXB0PT0NCi8vIEBuYW1lICAgICAgICAgICBBdX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ZWNrZWQiOw0KICANCiAgLy8gYmxhbmsgdGV4dGJveCBhbmQgZm9jdXMgaXQNCiAgdGV4dGJveC52YWx1ZSA9ICIiOw0KICB0ZXh0Ym94LmZvY3VzKCk7DQoNCn0pKCk7">changevaluesonhixiedatauripage.user.js</a>
Linkify bug numbers - test: bug 258287

alta88
 
Posts: 1003
Joined: January 28th, 2006, 3:08 pm

Post Posted May 26th, 2006, 1:14 am

pile0nades - findbarontop is nice.

i've done some customization on findbar and this line

Code: Select all
if (event.target.getAttribute("id") == "find-closebutton") {


no longer works (i use it to clear the field and dehighlight on close). and i can't find findbar anywhere in DOMi now either..

any ideas?

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 4 guests