[Ext] userChrome.js
- KidReefer
- Posts: 141
- Joined: May 7th, 2006, 6:10 am
- Location: Earth...mainly
- Contact:
- Diorser
- Posts: 1009
- Joined: June 22nd, 2005, 6:57 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";');
-
- Posts: 1029
- Joined: January 28th, 2006, 3:08 pm
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.
-
- Posts: 0
- Joined: December 31st, 1969, 5:00 pm
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
- Posts: 1009
- Joined: June 22nd, 2005, 6:57 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
- Posts: 548
- Joined: September 15th, 2005, 4:17 pm
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.
<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.
- XerBlade
- Posts: 865
- Joined: October 4th, 2005, 10:45 pm
- Location: Nashville, TN, US
-
- Posts: 2031
- Joined: February 6th, 2004, 11:59 am
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
- Posts: 1009
- Joined: June 22nd, 2005, 6:57 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
- Posts: 548
- Joined: September 15th, 2005, 4:17 pm
- Diorser
- Posts: 1009
- Joined: June 22nd, 2005, 6:57 am
-
- Posts: 8
- Joined: April 18th, 2006, 6:58 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.
-
- Posts: 0
- Joined: December 31st, 1969, 5:00 pm
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).