MozillaZine

[Ext] userChrome.js

Announce and Discuss the Latest Theme and Extension Releases.
KidReefer

User avatar
 
Posts: 141
Joined: May 7th, 2006, 6:10 am
Location: Earth...mainly

Post Posted June 4th, 2006, 4:01 am

If it wasnt in the right place or labeled correctly it wouldnt have loaded properly.
I think it was a case of right code wrong place. glad it works. Enjoy!

Diorser

User avatar
 
Posts: 960
Joined: June 22nd, 2005, 6:57 am

Post Posted June 4th, 2006, 5:52 am

zeniko wrote:
Code: Select all
document.getElementsByAttribute("key", "manBookmarkKb")[0].setAttribute("oncommand", '(getBrowser().selectedTab = getBrowser().addTab("chrome://browser/content/bookmarks/bookmarksManager.xul")).label = "Bookmarks Manager";');

This works like a charm to open Bookmark manager in a tab;

Is it possible to do the same for the Download button so that it opens in a tab, instead of the small floating window ?

It should be very close to this (?), but does not work...
Code: Select all
document.getElementsByAttribute("key", "&downloads.commandkey")[0].setAttribute("oncommand", '(getBrowser().selectedTab = getBrowser().addTab("chrome://mozapps/content/downloads/downloads.xul")).label = "Download Manager";');

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

Post Posted June 4th, 2006, 6:59 am

Code: Select all
/* :::::::: No New Window on Double Click ::::::::::::::: */
eval("FolderPaneDoubleClick = " + FolderPaneDoubleClick.toString().replace(/else {[^}]+}/, ""));


changing the else statement in the function to blank at runtime? that is absolutely clever! minus one extension..

a question - to use getElementById eg. on an id in the Tb compose window, can that only be done on a load of the compose window? if so, is the only way to have that execute from userchrome.js is to add an eventlistener, and if so, what exactly would it listen for?

thanks.

old zeniko
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted June 4th, 2006, 7:31 am

Diorser wrote:Is it possible to do the same for the Download button so that it opens in a tab, instead of the small floating window ?

Code: Select all
document.getElementById("Tools:Downloads").setAttribute("oncommand", '(getBrowser().selectedTab = getBrowser().addTab("chrome://mozapps/content/downloads/downloads.xul")).label = "Download Manager";');


alta88 wrote:a question - to use getElementById eg. on an id in the Tb compose window, can that only be done on a load of the compose window?

userChrome.js currently only affects the main window (where getElementById is directly available, as you can see in the examples I posted). To get a script into the compose window, you'll have to use the WindowHook snippet and add a listener for "chrome://messenger/content/messengercompose/messengercompose.xul".

Diorser

User avatar
 
Posts: 960
Joined: June 22nd, 2005, 6:57 am

Post Posted June 4th, 2006, 7:59 am

zeniko wrote:
Code: Select all
document.getElementById("Tools:Downloads").setAttribute("oncommand", '(getBrowser().selectedTab = getBrowser().addTab("chrome://mozapps/content/downloads/downloads.xul")).label = "Download Manager";');

Wonderful ! TTTTHHHAAANNKKK You so much !

I would not like to abuse... but it seems so easy to you.......
Then a very last one before next year (or may be one more time...)

How to make download open in a tab by default (when open by the system).
I hate the small download window with big icons....

dougeeebear

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

Post Posted June 4th, 2006, 10:40 am

I don't like to abuse either (you've certainly helped me out enough), but I've been trying to get the

<a href="data:application/x-javascript;charset=utf-8;base64,PG92ZXJsYXkgaWQ9Im1hbmFnZUJvb2ttYXJrc0ZvbGRlcnMiDQogICB4bWxucz0iaHR0cDovL3d3dy5tb3ppbGxhLm9yZy9rZXltYXN0ZXIvZ2F0ZWtlZXBlci90aGVyZS5pcy5vbmx5Lnh1bCI%2BDQoNCjxzY3JpcHQgdHlwZT0iYXBwbGljYXRpb24veC1qYXZhc2NyaXB0Ij4NCnZhciBvbGRCb29rbWFya3NHZXRDb21tYW5kcyA9IHdpbmRvdy5Cb29rbWFya3NDb21tYW5kLmdldENvbW1hbmRzOw0KDQpCb29rbWFya3NDb21tYW5kLmdldENvbW1hbmRzID0gZnVuY3Rpb24gKG5vZGUsIHBhcmVudCwgZHMpDQp7DQogICAgdmFyIGNtZHMgPSBvbGRCb29rbWFya3NHZXRDb21tYW5kcyhub2RlLCBwYXJlbnQsIGRzKTsNCiAgICB2YXIgdHlwZSA9IEJvb2ttYXJrc1V0aWxzLnJlc29sdmVUeXBlKG5vZGUsIGRzKTsNCiAgICBpZih0eXBlID09ICJGb2xkZXIiKSBjbWRzLl9pbm5lci5zcGxpY2UoMSwgMCwgUkRGLkdldFJlc291cmNlKGdOQ19OU19DTUQgKyAnYm1fbWFuYWdlZm9sZGVyJykgKTsNCiAgICBpZih0eXBlID09ICJQZXJzb25hbFRvb2xiYXJGb2xkZXIiKSBjbWRzLl9pbm5lci5zcGxpY2UoMSwgMCwgUkRGLkdldFJlc291cmNlKGdOQ19OU19DTUQgKyAnYm1fbWFuYWdlZm9sZGVyJykgKTsNCiAgICByZXR1cm4gY21kczsNCn0NCjwvc2NyaXB0Pg0KDQo8IS0tIEZpcmVmb3ggQm9va21hcmsgQ29udGV4dCBNZW51IC0tPg0KICA8bWVudXBvcHVwIGlkPSJib29rbWFya3MtY29udGV4dC1tZW51Ij4NCiAgICA8bWVudWl0ZW0gY29tbWFuZD0iY21kX2JtX21hbmFnZWZvbGRlciIgbGFiZWw9Ik1hbmFnZSBGb2xkZXIiLz4NCiAgPC9tZW51cG9wdXA%2BDQoNCjwvb3ZlcmxheT4%3D">ManageBookmarksFolders.xul</a> snippet

to open in a new tab instead of a window, and I'm not having any luck with it.
(and you're on a roll here with opening things in tabs) :)

This snippet adds a "Manage Folder" item to the Bookmarks context menu.
Last edited by dougeeebear on June 4th, 2006, 11:11 am, edited 2 times in total.

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

Post Posted June 4th, 2006, 10:48 am

worked perfectly first try. userchrome.js is too cool..

XerBlade

User avatar
 
Posts: 865
Joined: October 4th, 2005, 10:45 pm
Location: Nashville, TN, US

Post Posted June 5th, 2006, 7:06 pm

Anyone know a way I can add a toolbar buttons to the ends of the tab bar (without using one of the extensions that adds small actual toolbars to the ends of it)?
And, while I'm at it, move already existing buttons there?
User Agent
Extensions
AMD64/2.41GHz RAM/1.0GB ATI/256MB-GDDR3/128-bit/8xAGP Cable6.0M/384kbps

AnonEmoose
 
Posts: 2031
Joined: February 6th, 2004, 11:59 am

Post Posted June 5th, 2006, 7:42 pm

dougeeebear wrote:I don't like to abuse either (you've certainly helped me out enough), but I've been trying to get the

<a href="data:application/x-javascript;charset=utf-8;base64,PG92ZXJsYXkgaWQ9Im1hbmFnZUJvb2ttYXJrc0ZvbGRlcnMiDQogICB4bWxucz0iaHR0cDovL3d3dy5tb3ppbGxhLm9yZy9rZXltYXN0ZXIvZ2F0ZWtlZXBlci90aGVyZS5pcy5vbmx5Lnh1bCI%2BDQoNCjxzY3JpcHQgdHlwZT0iYXBwbGljYXRpb24veC1qYXZhc2NyaXB0Ij4NCnZhciBvbGRCb29rbWFya3NHZXRDb21tYW5kcyA9IHdpbmRvdy5Cb29rbWFya3NDb21tYW5kLmdldENvbW1hbmRzOw0KDQpCb29rbWFya3NDb21tYW5kLmdldENvbW1hbmRzID0gZnVuY3Rpb24gKG5vZGUsIHBhcmVudCwgZHMpDQp7DQogICAgdmFyIGNtZHMgPSBvbGRCb29rbWFya3NHZXRDb21tYW5kcyhub2RlLCBwYXJlbnQsIGRzKTsNCiAgICB2YXIgdHlwZSA9IEJvb2ttYXJrc1V0aWxzLnJlc29sdmVUeXBlKG5vZGUsIGRzKTsNCiAgICBpZih0eXBlID09ICJGb2xkZXIiKSBjbWRzLl9pbm5lci5zcGxpY2UoMSwgMCwgUkRGLkdldFJlc291cmNlKGdOQ19OU19DTUQgKyAnYm1fbWFuYWdlZm9sZGVyJykgKTsNCiAgICBpZih0eXBlID09ICJQZXJzb25hbFRvb2xiYXJGb2xkZXIiKSBjbWRzLl9pbm5lci5zcGxpY2UoMSwgMCwgUkRGLkdldFJlc291cmNlKGdOQ19OU19DTUQgKyAnYm1fbWFuYWdlZm9sZGVyJykgKTsNCiAgICByZXR1cm4gY21kczsNCn0NCjwvc2NyaXB0Pg0KDQo8IS0tIEZpcmVmb3ggQm9va21hcmsgQ29udGV4dCBNZW51IC0tPg0KICA8bWVudXBvcHVwIGlkPSJib29rbWFya3MtY29udGV4dC1tZW51Ij4NCiAgICA8bWVudWl0ZW0gY29tbWFuZD0iY21kX2JtX21hbmFnZWZvbGRlciIgbGFiZWw9Ik1hbmFnZSBGb2xkZXIiLz4NCiAgPC9tZW51cG9wdXA%2BDQoNCjwvb3ZlcmxheT4%3D">ManageBookmarksFolders.xul</a> snippet

to open in a new tab instead of a window, and I'm not having any luck with it.
(and you're on a roll here with opening things in tabs) :)

This snippet adds a "Manage Folder" item to the Bookmarks context menu.

something like this should work (you need to eval or overwrite the manage folder function)... haven't tested it....

getBrowser().addTab("chrome://browser/content/bookmarks/bookmarksManager.xul");

Diorser

User avatar
 
Posts: 960
Joined: June 22nd, 2005, 6:57 am

Post Posted June 6th, 2006, 3:21 am

Small summary / how to open in tabs:

Code: Select all
// JavaScript Document

/* Bookmark Manager open in Tab */
document.getElementsByAttribute("key", "manBookmarkKb")[0].setAttribute("oncommand", '(getBrowser().selectedTab = getBrowser().addTab("chrome://browser/content/bookmarks/bookmarksManager.xul")).label = "Bookmarks Manager";');

/* Download Manager open in Tab */
document.getElementById("Tools:Downloads").setAttribute("oncommand", '(getBrowser().selectedTab = getBrowser().addTab("chrome://mozapps/content/downloads/downloads.xul")).label = "Download Manager";');

/* History Manager open in Tab */
document.getElementById("viewHistorySidebar").setAttribute("oncommand", '(getBrowser().selectedTab = getBrowser().addTab("chrome://browser/content/history/history-panel.xul")).label = "History Manager";');

dougeeebear

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

Post Posted June 6th, 2006, 3:51 am

@AnonEmoose:
@Diorser:
Thanks guys, but those don't seem to work.
I'm only opening up a bookmark folder (or sub-menu) not the complete bookmarks manager.

Diorser

User avatar
 
Posts: 960
Joined: June 22nd, 2005, 6:57 am

Post Posted June 6th, 2006, 5:32 am

This is the mystery of chrome.
I can confirm that the code I propose above is tested and works for me.

Only thing to improve for history manager: the Tab is not labelled "History Manager", but chrome://browser/content/history/history-panel.xul ...
Not so nice, but did not find the solution.

giuliastro
 
Posts: 8
Joined: April 18th, 2006, 6:58 am

Post Posted June 7th, 2006, 7:03 am

Could you explain a little better how this works? I installed your extension in Firefox and tried to create a userChrome.js file in my profile directory (I'm using Linux). Tried to paste some code there taken from the first page of this thread. Nothing happens. What am I doing wrong? Where should I create the file userChrome.js? Where can I find some documentation to write js to work with userChrome? Thanks a lot.

giuliastro
 
Posts: 8
Joined: April 18th, 2006, 6:58 am

Post Posted June 7th, 2006, 7:07 am

Did anybody try this with Thunderbird?

old zeniko
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted June 7th, 2006, 7:16 am

giuliastro wrote:Did anybody try this with Thunderbird?

Me myself, of course. See this post for some very basic examples.

Note that you shouldn't have to create the userChrome.js file yourself - the extension does that for you (it's located in the profile's chrome subfolder - where you'll also find userChrome.css and userContent.css).

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 3 guests