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

Announce and Discuss the Latest Theme and Extension Releases.
Locked
User avatar
gialloporpora
Posts: 362
Joined: October 24th, 2005, 12:44 pm

Re: [Ext] userChromeJS 1.2 [2010-07-22]

Post by gialloporpora »

alta88 wrote:

Code: Select all

if (location == "chrome://messenger/content/messenger.xul") {}



@alta88,
thank you for your help but unfortunatelly it doesn't work

This is my code:

Code: Select all


/* Sposta l'avviso di nuovo allegato in basso (grazie a @klades) */
if (location == "chrome://messenger/content/messengercompose/messengercompose.xul") {
var el = document.getElementById("customizeToolbarSheetPopup").nextSibling;
if (el.tagName == "hbox")
   document.getElementById("FormatToolbar").parentNode.insertBefore(el, document.getElementById("FormatToolbar"));
}


if (location == "chrome://messenger/content/messenger.xul") {
with (document.getElementById("folderNameCell")) setAttribute("properties",getAttribute("properties") + " account-?acct name-?folderTreeName");
}


The error is the same:

Code: Select all

Errore: document.getElementById("folderNameCell") is null


If it is too difficult no problem, I can use Mail-Tweak.
alta88
Posts: 1029
Joined: January 28th, 2006, 3:08 pm

Re: [Ext] userChromeJS 1.2 [2010-07-22]

Post by alta88 »

il nome corretto è "folderNameCol".. ;)
User avatar
gialloporpora
Posts: 362
Joined: October 24th, 2005, 12:44 pm

Re: [Ext] userChromeJS 1.2 [2010-07-22]

Post by gialloporpora »

@@alta88,
thanks again for your help but not works again.
I have tried the code suggested in the MozillaZine Wiki page:

Code: Select all

if (location == "chrome://messenger/content/messenger.xul") {
with (document.getElementById("folderNameCol")) setAttribute("properties", getAttribute("properties") + " name-?folderTreeName")
}


and also the code used in mail-tweak add-on:

Code: Select all

if (location == "chrome://messenger/content/messenger.xul") {
with (document.getElementById("folderNameCol")) setAttribute("properties",getAttribute("properties") + " account-?acct name-?folderTreeName");
}


but nothing happens :-(. If I spy the folder properties with the CSS Selector in Mail-Tweak I don't see these two properties:




PS: Do you know italian? :-)
alta88
Posts: 1029
Joined: January 28th, 2006, 3:08 pm

Re: [Ext] userChromeJS 1.2 [2010-07-22]

Post by alta88 »

the Tb folderpane has been changed quite a bit from Tb 2.0. does the functionality work in MailTweak and Tb3? note that it needs to be accompanied by the proper css rule. it actually doesn't seem like correct code for adding pseudo properties to a tree cell.

i don't use this nor do much with Tb anymore, but am quite familiar with how to do this in, for example, the Fx Places tree. perhaps i will post some code to apply any 'atom' to a tree column which will allow it to be referenced for custom css styling.

c'era una volta sono stato a roma qualche anno, sembrava una buona idea imparare qualche parola..
User avatar
gialloporpora
Posts: 362
Joined: October 24th, 2005, 12:44 pm

Re: [Ext] userChromeJS 1.2 [2010-07-22]

Post by gialloporpora »

@alta88,
thank you for your reply, and sorry for the long delay of my reply, but I have no see notification and I have no connection to internet for some weeks.

The code works with the mail-tweak add-on, and the CSS code is working if I activate the tweak in mail-tweak.

No problem, I use mail-tweak.
Thanks again
Ciao
Sandro
Sloonz
Posts: 1
Joined: October 22nd, 2010, 3:07 am

Re: [Ext] userChromeJS 1.2 [2010-07-22]

Post by Sloonz »

Hello,

I can’t access to on* attributes on the DOM ; this example prints "undefined" on the console, and then trigger this error :

Error: Component is not available = NS_ERROR_NOT_AVAILABLE
Source file: chrome://userchromejs/content/userChromeJS.js -> file:///Users/sloonz/Library/Application%20Support/Firefox/Profiles/atn1tz86.dev/chrome/test.js
Line: 6


Code: Select all

document.addEventListener("DOMContentLoaded", function(event) {
   var doc = event.target;
   if(doc.location == "http://localhost/~moonz/test.html") {
         var elem = doc.getElementsByTagName("a")[0];
         userChrome.log(elem["auieauieauieauieauie"]);
         userChrome.log(elem["onclick"]);
   }
}, false);


I am doing something wrong ? (note: test.html just contains <a href="http://www.google.fr">test</a>)
ushawn
Posts: 15
Joined: May 24th, 2010, 11:37 pm

Re: [Ext] userChromeJS 1.2 [2010-07-22]

Post by ushawn »

In recent firefox release, mozIJSSubscriptLoader::loadSubScript interface has supported specifying the character encoding, please update userChromeJS extension to use this parameter to support double-byte characters. So we can use local language characters directly in the script files instead of escaping them using unicode sequences, because when writing scripts that use localized strings, it's a real pain to maintain \u escapes, the script becomes unreadable. That is a great convenient to local developers.
alta88
Posts: 1029
Joined: January 28th, 2006, 3:08 pm

Re: [Ext] userChromeJS 1.2 [2010-07-22]

Post by alta88 »

i'd have no problem doing this, but i don't think it's available in either the .idl definition or the code, to pass in this arg..

http://mxr.mozilla.org/mozilla-central/ ... der.cpp#97
ushawn
Posts: 15
Joined: May 24th, 2010, 11:37 pm

Re: [Ext] userChromeJS 1.2 [2010-07-22]

Post by ushawn »

it seems the interface has been changed back again...

I've been using firefox4 nightly build, and it indeed doesn't support this arg any more in current build.
alta88
Posts: 1029
Joined: January 28th, 2006, 3:08 pm

Re: [Ext] userChromeJS 1.2 [2010-07-22]

Post by alta88 »

it seems like a reasonable thing, and although the arg is gone, the code comments are still there. perhaps you could check the change history on that module, track it to a bug, and see what they're saying in the comments there.
User avatar
gialloporpora
Posts: 362
Joined: October 24th, 2005, 12:44 pm

Re: [Ext] userChromeJS 1.2 [2010-07-22]

Post by gialloporpora »

I have solved my problem looking at the mail-tweak extension source code, it have different loaders for different TB version.

To make the tweak to style folder icon in TB3 use this code:

Code: Select all

if (location == "chrome://messenger/content/messenger.xul") {
   AS = Components.classes["@mozilla.org/atom-service;1"].getService(Components.interfaces.nsIAtomService);
   spa = setPropertyAtoms;
setPropertyAtoms = function (folder, props) {
spa(folder, props);
function add(a) {props.AppendElement(AS.getAtom(a))}
function pretty(s){
   s=s.replace(/\s/g, "_");
   s=s.replace(/[^a-zA-Z\d_\-]+/g, "");
   return s.toLowerCase();
}
add("account-" + pretty(folder.rootFolder.prettiestName));
add("name-" + pretty(folder.prettiestName));
add('mode-'+gFolderTreeView.mode);
}
}





I have only added the "pretty" function to remove characters not permitted in stylesheets, spaces are replaced by underscore.
Edit: Added the possibility to know view mode to style in a different way folder depending from folder view mode (smart, favorite, all, ecc…), this is the only reason that I have prefered modify the code instead of using mail-tweak add-on, I linke to view Gmail icon in all folders when I am in Unified view (Smart folders).



Sandro
SevenSeven
Posts: 33
Joined: February 8th, 2004, 1:05 pm

Re: [Ext] userChromeJS 1.1 [2009-05-22]

Post by SevenSeven »

Here's some of my code that was presented earlier in this thread, updated for Firefox 4b11.
  • Clear the searchbar after submit & open in new fg tab or current tab if empty
  • Open urlbar queries in new fg tab or in current tab if empty
  • Open bookmark-menu, Library & bookmarks/history sidebar URIs in new fg tab or in current tab if empty
  • Open history-menu URIs in new fg tab or in current tab if empty
  • Open external app links in new tab or in current tab if empty

Code: Select all

if (location == "chrome://browser/content/browser.xul") {

/*======= Clear the searchbar after submit & open in new fg tab or current tab if empty (browser.search.openintab = false) =======*/

// search.xml
var ucSearchbar = {
   init: function() {
      this.searchbar = document.getElementById("searchbar");
      if (!this.searchbar) return;
      var str = this.searchbar.handleSearchCommand.toString().replace('this.d','if (where == "current" && !isTabEmpty(gBrowser.selectedTab)) where = "tab"; setTimeout("ucSearchbar.searchbar.value=\'\';",0); $&');
      eval("ucSearchbar.searchbar.handleSearchCommand = " + str);
   }
};
ucSearchbar.init();
eval("BrowserToolboxCustomizeDone = " + BrowserToolboxCustomizeDone.toString().replace('focus();','$& ucSearchbar.init();'));


/*======= Open urlbar queries in new fg tab or in current tab if empty =======*/

// urlbarBindings.xml
(function() {
var urlbar = document.getElementById("urlbar");
var str = urlbar.handleCommand.toString();
str = str.replace("ope","if (where == 'current' && !/^javascript\:/i.test(url) && !isTabEmpty(gBrowser.selectedTab)) where = 'tab'; $&");
str = str.replace("aTriggeringEvent &&","");
str = str.replace("aTriggeringEvent.altKey","!/^javascript\:/i.test(url)");
eval("urlbar.handleCommand = " + str);


/*======= Open bookmark-menu, Library & bookmarks/history sidebar URIs in new fg tab or in current tab if empty =======*/

// modules\PlacesUIUtils.jsm
if (typeof PlacesUIUtils.aa == 'undefined') {
   PlacesUIUtils.aa = true;
   PlacesUIUtils.pu = PlacesUtils;
   str = PlacesUIUtils._openNodeIn.toString().replace('PlacesUtils','this.pu','g');
   str = str.replace('aWindow.','var browserWin = this._getTopBrowserWin(); if (browserWin) { if (!browserWin.isTabEmpty(browserWin.gBrowser.selectedTab) && !/^j/.test(aNode.uri) && aWhere == "current") aWhere = "tab"; } $&');   //http://forums.mozillazine.org/viewtopic.php?p=3201065#3201065
   eval("PlacesUIUtils._openNodeIn = " + str);
   str = PlacesUIUtils._openTabset.toString().replace('ue;','$& if (!browserWindow.isTabEmpty(browserWindow.gBrowser.selectedTab)) replaceCurrentTab = false;');
   eval("PlacesUIUtils._openTabset = " + str);
}
})();


/*======= Open history-menu URIs in new fg tab or in current tab if empty =======*/

// browser.js
eval("HistoryMenu.prototype._onCommand = " + HistoryMenu.prototype._onCommand.toString().replace("uri);","$& if (!isTabEmpty(gBrowser.selectedTab) && (aEvent == null || (!aEvent.ctrlKey && !aEvent.shiftKey && !aEvent.altKey))) { gBrowser.selectedTab = gBrowser.addTab(); }"));


/*======= Open external app links in new tab or in current tab if empty =======*/

// browser.js
// only applies if browser.link.open_newwindow = 3
eval('nsBrowserAccess.prototype.openURI = ' + nsBrowserAccess.prototype.openURI.toString().replace("switch","if (isExternal && aWhere == Ci.nsIBrowserDOMWindow.OPEN_NEWTAB && isTabEmpty(gBrowser.selectedTab)) aWhere = Ci.nsIBrowserDOMWindow.OPEN_CURRENTWINDOW; $&"));

} //chrome://browser/content/browser.xul
Last edited by SevenSeven on February 9th, 2011, 12:37 am, edited 2 times in total.
mad.engineer
Posts: 314
Joined: August 8th, 2006, 4:08 pm

Re: [Ext] userChromeJS 1.2 [2010-07-22]

Post by mad.engineer »

Is userChromeJS v1.3 compatible with 3.1.7?. I tried installing it and got error that it is not compatible. Thanks
K4RBQT99
Posts: 284
Joined: November 11th, 2010, 3:23 pm

Re: [Ext] userChromeJS 1.2 [2010-07-22]

Post by K4RBQT99 »

Hi,
First, thanks for the work with this extension.
Somebody can to help me to compatibility the script SearchClipboard.uc.js for to work with the Organize Search Engines extension? I think that I need only to change the last lines (cited below), I see what the extension remove the original menupopup from the engine button, and I don't know how to find the correct element for to add the eventListener ](*,)

Code: Select all

var searchbar = document.getElementById("searchbar");

// middle-click the search engine popup to search clipboard
document.getAnonymousElementByAttribute(searchbar, "anonid", "searchbar-popup").addEventListener("click", searchClipboard, false);

// middle-click the search engine button to search clipboard
document.getAnonymousElementByAttribute(searchbar, "anonid", "searchbar-engine-button").addEventListener("click", searchClipboard, false);
alta88
Posts: 1029
Joined: January 28th, 2006, 3:08 pm

Re: [Ext] userChromeJS 1.3 [2011-02-22]

Post by alta88 »

userChromeJS v1.3 released.

@K4RBQT99, you should probably install DOM Inspector (on AMO) so you can look up ids.. don't use that extension myself.
Locked