[Ext] userChrome.js

Announce and Discuss the Latest Theme and Extension Releases.
Locked
old zeniko
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Re: userChrome.js

Post by old zeniko »

@AnonEmoose: Nice one. Do you think such XUL overlays would be broadly used? Might get some more input for the discussion over at MozillaWiki.

alta88 wrote:if netscape (7.2) mail only is selected as default, the script will not run.

Interesting. This does work for SeaMonkey and should just as well work for good ol' Netscape. But since I've got no Netscape installation lying around and probably won't have any Netscape users anyway, I'll leave it at that. Should anybody want to further investigate, I'll accept patches...
AnonEmoose
Posts: 2031
Joined: February 6th, 2004, 11:59 am

Re: userChrome.js

Post by AnonEmoose »

zeniko wrote:@AnonEmoose: Nice one. Do you think such XUL overlays would be broadly used? Might get some more input for the discussion over at MozillaWiki.
Probably less now-a-days then before, since implementation of the install.rdf/chrome.manifest introduced in 1.5. However, it could be still be useful for extension development/testing (before rolling an xpi), or quick/dirty hacks you want to try out or keep seperate. Also with these overlays one could add dtd/properties/js/css files.

I generally use it to keep individual snippets seperated (and customize or add menu items instead of pure JS to create elements) and disabling a particular overlay is as easy as commenting out the line....

eg it can be used instead of or convert the menu entry on Tools folder from the js file to an xul file.

example custom overlay

Code: Select all

<overlay id="customOpenChromeFolder"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

              <menupopup id="menu_ToolsPopup">
         <menuitem label="Open 'chrome' Folder..." accesskey="h" oncommand='Components.classes["@mozilla.org/file/directory_service;1"].
getService(Components.interfaces.nsIProperties).get("UChrm", Components.interfaces.nsILocalFile).launch();'/>
      </menupopup>
</overlay>


example userChrome.xul

Code: Select all

<!-- Insert the following line for EACH custom overlay -->
<?xul-overlay href="userChromeOverlays/customOpenChromeFolder.xul"?>




<overlay id="pick-a name-you-like"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
</overlay>
********
Posts: 947
Joined: August 24th, 2005, 12:23 pm

Post by ******** »

wow! new versions!
i have 0.5, back when it didn't even have a thread.
time to upgrade!

inifinitely useful!
alta88
Posts: 1029
Joined: January 28th, 2006, 3:08 pm

Re: userChrome.js

Post by alta88 »

zeniko wrote: should just as well work for good ol' Netscape. But since I've got no Netscape installation lying around


well then how can you advertise it works for netscape? are you a tarot card reader or software developer? :D
perhaps a Known Issues or WONTFIX disclaimer would be appropriate.

i use NS7.2 mail exclusively for reading email and would gladly contribute a patch if i could..
old zeniko
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Re: userChrome.js

Post by old zeniko »

alta88 wrote:well then how can you advertise it works for netscape? are you a tarot card reader or software developer? :D

zeniko wrote:This release should work for ...

To be honest, I've only tested it with Firefox and SeaMonkey. It should work just as well with all other applications mentioned (it's so simple I don't see why it shouldn't), but I don't care too much about actually verifying that. Consider your post a contribution to the "Known Issues" section (since I haven't verified your claim, I wouldn't be much better off than reading my cards if I officially saw this as an issue ;))...
********
Posts: 947
Joined: August 24th, 2005, 12:23 pm

Post by ******** »

is it possible to add an overlay or script for other windows or dialogs?

i'm trying to apply my script to chrome://stylish/content/stylish.xul and chrome://stylish/content/stylish.xul?sidebar=1
User avatar
mrtech
Posts: 2007
Joined: May 15th, 2003, 7:46 am
Location: New York
Contact:

Post by mrtech »

<li> Updated <a href="data:application/x-javascript;charset=utf-8;base64,LyogIFRoaXMgc2NyaXB0IHdpbGwgYWRkICJFZGl0IHVzZXJDaHJvbWUuanMiIG1lbnVpdGVtIGluDQogICAgTVIgVGVjaCBMb2NhbCBJbnN0YWxsJ3MgRWRpdCBDb25maWcgQnV0dG9uIE1lbnUgdmVyc2lvbiAxLjMgICAgKi8NCg0KKGZ1bmN0aW9uKCkgew0KDQogIGZ1bmN0aW9uIGluc2VydE1lbnVJdGVtKHRoaXNNZW51SXRlbUlELCB0aGlzQ21kKQ0KICB7DQogICAgdmFyIGVkaXRDb25maWdNZW51ID0gZG9jdW1lbnQNCiAgICAgICAgLmdldEVsZW1lbnRCeUlkKHRoaXNNZW51SXRlbUlEKS5maXJzdENoaWxkOw0KICANCiAgICBpZighZWRp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Q2hybScpLCAndXNlckNocm9tZS5qcycsICdsb2NhbF9pbnN0YWxsLmRlZmF1bHRfSlNfZWRpdG9yJywgdHJ1ZSk7IjsNCg0KICBpbnNlcnRNZW51SXRlbSgiZWRpdGNvbmZpZ2ZpbGVzLXRvb2xiYXItYnV0dG9uIiwgY21kKTsNCiAgaW5zZXJ0TWVudUl0ZW0oInRvb2xzX2VkaXRfbXlfY29uZmlnIiwgY21kKTsNCg0KfSkoKTsNCg0KDQo%3D">Add 'Edit userChrome.js' on MR Tech Local Install's Edit Config button menu</a> this works with 4.6.4
mel reyes • mrtech.com • BlogPlaxoLinkedInTwitter
Support mrtech.com get our toolbar
old zeniko
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by old zeniko »

desertfox wrote:is it possible to add an overlay or script for other windows or dialogs?

I was thinking about applying userChrome.js to all windows (as is done for userChrome.css), but then you'd have to add some boilerplate code around all your snippets to make sure you're in the right window (which practically prevents to have one-line solutions to common issues). For convenience, I've thus settled with the solution we're having right now.

What you can do however is use the newly added WindowHook snippet and then register a function to be called for the other window. For your case, this would look as follows :

Code: Select all

WindowHook.register("chrome://stylish/content/stylish.xul", function(aWindow) {
   // use aWindow instead of window and aWindow.document instead of document
});
User avatar
Philip Chee
Posts: 6475
Joined: March 1st, 2005, 3:03 pm
Contact:

Post by Philip Chee »

?!? The nsIWindowsHooks.idl doesn't define ::register ?!?

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

Post by old zeniko »

Philip Chee wrote:?!? The nsIWindowsHooks.idl doesn't define ::register ?!?

Apparently not. :) OTOH I never mentioned nsIWindowsHooks, but WindowHook (a snippet newly added to the first post).
********
Posts: 947
Joined: August 24th, 2005, 12:23 pm

Post by ******** »

zeniko wrote:
desertfox wrote:is it possible to add an overlay or script for other windows or dialogs?

What you can do however is use the newly added WindowHook snippet and then register a function to be called for the other window. For your case, this would look as follows :

Code: Select all

WindowHook.register("chrome://stylish/content/stylish.xul", function(aWindow) {
   // use aWindow instead of window and aWindow.document instead of document
});

sweet. it worked, thanks.
User avatar
Philip Chee
Posts: 6475
Joined: March 1st, 2005, 3:03 pm
Contact:

Post by Philip Chee »

zeniko wrote:Apparently not. :) OTOH I never mentioned nsIWindowsHooks, but WindowHook (a snippet newly added to the first post).
Ooopsies. I don't usually look back at the earlier posts, only at the latest. Sorry.

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

Post by dougeeebear »

zeniko wrote:What you can do however is use the newly added WindowHook snippet and then register a function to be called for the other window. For your case, this would look as follows :

Code: Select all

WindowHook.register("chrome://stylish/content/stylish.xul", function(aWindow) {
   // use aWindow instead of window and aWindow.document instead of document
});

I was thinking that the WindowHook snippet could be installed in userChrome.js, and then all registered functions would work off of that separately in a uc.js file.

But it would appear that each registered function has to be attached to its own WindowHook snippet.
Is this correct?
old zeniko
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by old zeniko »

You shouldn't have to include the WindowHook snippet more than once. Make sure that you're using the Sub-Script Loader based on setTimeout (available from the first post), otherwise the WindowHook object won't be available for the .uc.js files (unless you've inserted the WindowHook snippet above the Sub-Script Loader snippet).
AnonEmoose
Posts: 2031
Joined: February 6th, 2004, 11:59 am

Post by AnonEmoose »

also, if you use importScript instead of subScript just make sure WindowHook.js is one of the first importScript lines.......

eg

Code: Select all

importScript("userChromeScripts/userWindowHook.js");
importScript("userChromeScripts/foo.js");
importScript("userChromeScripts/foo1.js");
importScript("userChromeScripts/foo2.js");
importScript("userChromeScripts/foo3.js");
importScript("userChromeScripts/foo4.js");



zeniko a WindowHook-like function for targeted window overlays should be fairly straight forward as well
Locked