MozillaZine

[Ext] userChromeJS 2.0 [2015-08-02]

Announce and Discuss the Latest Theme and Extension Releases.
morat
 
Posts: 2275
Joined: February 3rd, 2009, 6:29 pm

Post Posted September 24th, 2011, 8:00 am

Is this an extension bug or do I not understand how the compose window works?

Code: Select all
/* Thunderbird 6.0.2 userChromeJS 1.4 */

if (location == "chrome://messenger/content/messengercompose/messengercompose.xul") {
  Components.classes["@mozilla.org/consoleservice;1"].
    getService(Components.interfaces.nsIConsoleService).
    logStringMessage("test");
}

What steps will reproduce the problem?

1. open thunderbird
2. open error console window
3. open and close compose window
4. open and close compose window

What is the expected result?

The message is shown twice.

What happens instead?

The message is shown once.
Last edited by morat on January 19th, 2012, 11:16 am, edited 1 time in total.

Philip Chee

User avatar
 
Posts: 6475
Joined: March 1st, 2005, 3:03 pm

Post Posted September 24th, 2011, 9:26 am

morat wrote:Is this an extension bug or do I not understand how the compose window works?

The compose window isn't really closed. It's recycled to avoid reinitializing a lot of stuff.

Phil

morat
 
Posts: 2275
Joined: February 3rd, 2009, 6:29 pm

Post Posted September 24th, 2011, 10:17 am

@Philip Chee

Ah, I see now. Thanks for reply.

barbarastreisand
 
Posts: 37
Joined: September 20th, 2011, 5:24 pm

Post Posted September 26th, 2011, 12:02 pm

Discussion At Bugzilla (Can't get a code to work):

lola:

Issues with code:

/* Firefox userChrome.js */

if (location == "chrome://browser/content/browser.xul") {
document.getElementById("main-window").setAttribute("screenX", "-2");
document.getElementById("main-window").setAttribute("screenY", "0");
document.getElementById("main-window").setAttribute("width", "1026");
document.getElementById("main-window").setAttribute("height", "741");
document.getElementById("main-window").setAttribute("sizemode", "normal");

Along with userchromejs 1.4


Actual results:

Not functioning even though this works with "daily" (tb):

/* Thunderbird userChrome.js */

if (location == "chrome://messenger/content/messengercompose/messengercompose.xul") {
document.getElementById("msgcomposeWindow").setAttribute("screenX", "398");
document.getElementById("msgcomposeWindow").setAttribute("screenY", "157");
document.getElementById("msgcomposeWindow").setAttribute("width", "571");
document.getElementById("msgcomposeWindow").setAttribute("height", "548");
document.getElementById("msgcomposeWindow").setAttribute("sizemode", "normal");
}


aceman 2011-09-24 05:25:54 PDT

Well, it seems I cannot reproduce it on linux, only on Win XP. On that machine I cannot do regression testing.

And there seems to be a bug in the extension. Even when I comment out the script in chrome/userchrome.js , it still does execute. Or when I update it, it does not pick up the new code. I found out an old cached copy of it is executing from startupcache/startupcache.4.little . When I delete the file, the script does update.

Can you try that, lola?

[reply] [-] Comment 18 lola 2011-09-24 06:16:39 PDT

I only have one startupcache.4.little: C:\Users\Administrator\AppData\Local\Mozilla\Firefox\Profiles\cxphk68s.default\startupCache

So i can safely delete that ?

[reply] [-] Comment 19 aceman 2011-09-24 06:26:21 PDT

Yes, delete the file inside it: startupcache.4.little. Or you can move it to some other place (keep a backup) in case you need to restore it.

[reply] [-] Comment 20 lola 2011-09-24 07:12:16 PDT

why would i need it ? moreover, firefox seems to have recreated it anyways.
i have the conviction that the script for userchromejs 1.4 is working actually,
"but", i have an issue .. . it's only working for new windows i close & reopen,
firefox's size & position aren't reminded but the default script's info is, so
it seems to work, But .. .

All sessions i reload, & that is another issue, cause i always reload
sessions through session manager, bypass the script, it seems that session
manager saves windows positions & restores them .. .

[reply] [-] Comment 21 lola 2011-09-25 11:09:22 PDT

Hi aceman, the author of session manager emailed me that answer:

Firefox itself is actually setting the window size and position bases on the values stored in the session data. Session Manager gets that data from Firefox. The only way to do what you want is if Session Manager removed the window position and size info from the session data. I don't think that would help in your case since your script would still run before Firefox finishes loading the window.

You should have your code run after the window loads by running it in an event listener as follows:

function onLoad(e) {

if (location == "chrome://browser/content/browser.xul") {
document.getElementById("main-window").setAttribute("screenX", "-2");
document.getElementById("main-window").setAttribute("screenY", "0");
document.getElementById("main-window").setAttribute("width", "1026");
document.getElementById("main-window").setAttribute("height", "741");
document.getElementById("main-window").setAttribute("sizemode", "normal");
}
}

window.addEventListener("load",onLoad,false);


But it's unfortunately not working, either .. .

[reply] [-] Comment 22 lola 2011-09-25 11:11:28 PDT

Is there a way to disable that:

"Firefox itself is actually setting the window size and position bases on the values stored in the session data" ?

maybe that will help

[reply] [-] Comment 23 aceman 2011-09-25 11:17:00 PDT

What about calling your function later, after Session restore has done it's stuff. Like:

function set_my_size () {
if (location == "chrome://browser/content/browser.xul") {
document.getElementById("main-window").setAttribute("screenX", "-2");
document.getElementById("main-window").setAttribute("screenY", "0");
document.getElementById("main-window").setAttribute("width", "1026");
document.getElementById("main-window").setAttribute("height", "741");
document.getElementById("main-window").setAttribute("sizemode", "normal");
}
}

function onLoad(e) {
setTimeout(set_my_size(),3000);
}

window.addEventListener("load",onLoad,false);

[reply] [-] Comment 24 lola 2011-09-25 15:16:18 PDT

Not working ((

[reply] [-] Comment 25 aceman 2011-09-26 02:57:01 PDT

Well, I don't know any more.
I tried this code:

function set_my_size () {
if (location == "chrome://browser/content/browser.xul") {
alert("ok");
document.getElementById("main-window").setAttribute("screenX", "-2");
document.getElementById("main-window").setAttribute("screenY", "0");
document.getElementById("main-window").setAttribute("width", "1026");
document.getElementById("main-window").setAttribute("height", "741");
document.getElementById("main-window").setAttribute("sizemode", "normal");
}
}

if (location == "chrome://browser/content/browser.xul") {
alert("init");
setTimeout(set_my_size,3000);
}

(window.addEventListener didn't work work me either.)

All the alerts get executed, so I don't know why the window size is not changed. That is a question for the author.
Remember to always delete the startupcache.4.little file after making any changes to the script. Also ask the author why that is necessary, if he can't invalidate the cache automatically from inside the extension.

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

Post Posted September 26th, 2011, 1:21 pm

userChromeJS executes the code it is given and as long as it does so there is no bug; it is certainly beyond its purview to know what issues may arise with the code it is given.

prior posts here mention how caching can be bypassed, either by code given to userChromeJS or by a command line switch on Fx/Tb startup. there will be no method included in the extension to clear caches.

userChromeJS runs in privileged mode and has all access, thus it is a developer tool for people who know what the code is doing. people should understand that blindly running code, which could be malicious, is unadvised. userChromeJS is not Stylish, despite its use there to do things css cannot do.

as for setting those attributes, with Session Manager and perhaps even core Fx, it should be completely unnecessary as far as remembering window position/dimensions. further, such things are OS specific, negative values may be illegal.

barbarastreisand
 
Posts: 37
Joined: September 20th, 2011, 5:24 pm

Post Posted September 26th, 2011, 9:54 pm

i use your extension in the case some devs could offer me a quicker fix than having to write an extension, & i'd really appreciate if you could please fix my code in order to keep all windows i open in the same size & position in firefox.

Also, if you know how to create codes for those unanswered requests, please help:

https://bugzilla.mozilla.org/show_bug.cgi?id=688284
https://bugzilla.mozilla.org/show_bug.cgi?id=688293
https://bugzilla.mozilla.org/show_bug.cgi?id=688459
https://bugzilla.mozilla.org/show_bug.cgi?id=688590

Miccovin
 
Posts: 51
Joined: February 9th, 2007, 12:44 am

Post Posted November 1st, 2011, 8:34 am

Hi folks,

is it possible to patch the script TabToTheRight from here:
Code: Select all
/* Open tab right to the current one  */
eval("gBrowser.addTab ="+gBrowser.addTab.toString().replace(
'if (!blank)',
'this.moveTabTo(t,this.mCurrentTab._tPos+1);'+
'if (!blank)'));

eval("gBrowser.moveTabTo = " + gBrowser.moveTabTo.toString().replace("this.mTabContainer.childNodes[i].selected = false;"));

/* For each tab opened in background, put the flag "unread" (until they are selected),
   in order to use css properties to change font color, etc. */
gBrowser.addEventListener("TabOpen", function(aEvent) { aEvent.originalTarget.setAttribute("unread", ""); }, false);
gBrowser.addEventListener("TabSelect", function(aEvent) { aEvent.originalTarget.removeAttribute("unread"); }, false);

It works buggy: After every restart it changes the taborder. After two restarts the order is like before (?).

Thx,
Mic

PS: Xubuntu 11.04, Fx 7.0.1

jikamens
 
Posts: 21
Joined: December 7th, 2011, 8:34 am

Post Posted January 19th, 2012, 8:17 am

There is a bug in userChromeJS 1.4 which prevents it from creating userChrome.js properly on recent Thunderbird and Firefox versions. The problem is that Thunderbird and Firefox no longer unpack XPI files by default -- they both leave them packed in the extensions directory and extract files from them as needed. userChromeJS expects the README.txt file to be available to copy into userChrome.js, but it's not there because it's in the XPI.
I'm not sure what the proper fix is, but something needs to be done. People installing userChromeJS for the first time are having trouble finding userChrome.js to edit it (since it's not there!).

Philip Chee

User avatar
 
Posts: 6475
Joined: March 1st, 2005, 3:03 pm

Post Posted January 19th, 2012, 11:20 am

jikamens wrote:There is a bug in userChromeJS 1.4 which prevents it from creating userChrome.js properly on recent Thunderbird and Firefox versions. The problem is that Thunderbird and Firefox no longer unpack XPI files by default -- they both leave them packed in the extensions directory and extract files from them as needed. userChromeJS expects the README.txt file to be available to copy into userChrome.js, but it's not there because it's in the XPI.
I'm not sure what the proper fix is, but something needs to be done. People installing userChromeJS for the first time are having trouble finding userChrome.js to edit it (since it's not there!).

Quick fix. add the following line to the install.rdf in the XPI:
Code: Select all
<em:unpack>true</em:unpack>

e.g.
Code: Select all
        <em:id>{3d7eb24f-2740-49df-8937-200b1cc08f8a}</em:id>
        <em:type>2</em:type>
        <em:unpack>true</em:unpack>
        <em:name>Flashblock</em:name>
        <em:version>1.3.19a1</em:version>

Phil

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

Post Posted January 22nd, 2012, 11:32 am

userChromeJS v1.5 has been released.

logan

User avatar
 
Posts: 3453
Joined: May 22nd, 2003, 3:51 pm
Location: NGC 2403

Post Posted October 14th, 2012, 10:17 am

Firefox 16 broke userChrome.js and a bunch of other extensions when it comes to popups and the load event. In Firefox 15 a userChrome.js with the following code will produce an alert for popup windows, but in 16 I get nothing:

Code: Select all
var appcontent = window.document.getElementById("appcontent");
if (appcontent)
  appcontent.addEventListener("DOMContentLoaded",
    function(e) {
      var document = e.target;
      if (!document.location)
        return;
      var href = document.location.href;
      alert(href);
    }, false);


Comments in bug 799348 make it sound like the preferred way of listening for an opened chrome window is to use the chrome-document-global-created observer. I replaced domwindowopened with that in components/userChrome_js.js and the above works again. I'm not sure when the chrome-document-global-created observer was added, but I assume there will be some compatibility issues for older products..

They checked in a fix for Firefox 19 but that's a way off yet and I guess there's some concern about breakage elsewhere, so I have no idea if they'll check this in to earlier future releases. Since this breaks Firebug and even the new builtin developer toolbar, maybe they'll get on this sooner rather than later.

Just thought I'd mention something here in case it wasn't on the radar already.

jikamens
 
Posts: 21
Joined: December 7th, 2011, 8:34 am

Post Posted October 15th, 2012, 6:39 am

The problem described earlier in this thread with modified userChrome.js files not being loaded when you restart Firefox or Thunderbird, unless you delete the startupCache or use one of the other workarounds described above, doesn't appear to have been fixed. Is there a way to fix it within the userChromeJS extension, or does it require a fix in the Mozilla core?

morat
 
Posts: 2275
Joined: February 3rd, 2009, 6:29 pm

Post Posted October 15th, 2012, 7:55 am

I think there should be a note about the -purgecaches command line option on the Home or FAQ page.

Why userChrome.js doesn't work every time I restart TB?
viewtopic.php?f=19&t=2541011

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

Post Posted October 16th, 2012, 10:02 am

there's no fix because there's no bug. this is an advanced tool (despite people using it to run privileged code without knowing code) and the -purgecaches flag is the correct way to handle changes by testers. permanently defeating the cache is incorrect.

a doc note is a good idea.

Arch321
 
Posts: 35
Joined: November 11th, 2010, 3:51 pm

Post Posted November 24th, 2012, 4:56 pm

Can userChromeJS be used to affect the modal and sizemode properties of a dialog box? For example, I would like to make the Thunderbird Account Settings dialog, AccountManager.xul, not be modal, and I would also like it to open maximized and to have min/max buttons. Is that possible? Thanks a lot

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 1 guest