MozillaZine

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

Announce and Discuss the Latest Theme and Extension Releases.
aeosynth
 
Posts: 4
Joined: April 10th, 2009, 3:59 am

Post Posted April 13th, 2009, 12:17 am

Instead of putting the entire status bar in the awesome bar, I just put the NoScript, Stylish, and Greasemonkey icons up there:

Code: Select all
var urlbar = document.getElementById("urlbar-icons")
var go = urlbar.lastChild

var sp = document.getElementById("stylish-panel")
sp.contextMenu = null
var ss = document.getElementById("stylish-strings")
var su = document.getElementById("stylish-url-strings")
var nsR = document.getElementById("noscript-statusRedirect")
var nsX = document.getElementById("noscript-statusXss")
var nsL = document.getElementById("noscript-statusLabel")
var nsI = document.getElementById("noscript-statusIcon")
var gmS = document.getElementById("gm-status")
var gmB = document.getElementById("gm-browser-bundle")

urlbar.insertBefore(nsI, go)
urlbar.insertBefore(nsL, go)
urlbar.insertBefore(nsX, go)
urlbar.insertBefore(nsR, go)
urlbar.insertBefore(su, go)
urlbar.insertBefore(ss, go)
urlbar.insertBefore(sp, go)
urlbar.insertBefore(gmB, go)
urlbar.insertBefore(gmS, go)


I put them in urlbar-icons b/c they kept jumping from the feed icon. insertBefore b/c I'm using Total ReChrome and the go button is permanently displayed. Stylish didn't disable the context menu, so I used sp.contextMenu = null. I used the Dom Inspector's Inspect Chrome Document to find out all the IDs.

The Greasemonkey icon has lots of padding on its left and right sides, is there any way to get rid of that?

Probably a n00b question, but where do I go to find out about properties like gBrowser and mTabContainer? Searching MDC reveals nothing.

Thanks! Great extension.

DavidRegev
 
Posts: 25
Joined: October 23rd, 2007, 2:14 am

Post Posted April 23rd, 2009, 2:11 pm

Smart Stop/Reload/Go Button

I have completed updating my Stop-Reload-Go Button script (which combines Stop, Reload, and Go into one dynamic button) for Firefox 3.x:
Image

Requirements for the script:
  1. userChromeJS (of course).
  2. The Smart Stop/Reload extension.
  3. The accompanying style, installed in Stylish.
And here is the new script, Smart Stop-Reload-Go Button.uc.js:
Code: Select all
// ==UserScript==
// @name            Smart Stop/Reload/Go Button
// @namespace       http://userstyles.org/styles/2131
// @description     Extends the ‘Smart Stop/Reload’ extension to combine with the Go button.
// @version         4
// @compatibility   Firefox 3.*
// @include         main
// @license         CC0 1.0 Universal (or later); http://creativecommons.org/publicdomain/zero/1.0/
// ==/UserScript==

// Move Smart Stop/Reload button into the location bar right before the Go button
document.getElementById('urlbar-icons').insertBefore(
    document.getElementById('stop-reload-container'),
    document.getElementById('go-button')
).
className = "urlbar-icon"

Notes
  • If the Stop and Reload buttons disappear for some reason, add them back to the toolbar and restart Firefox (or create a new window).
  • If the height of the button is off for your GTK+ theme, tweak the values at the end of the style (as is indicated there).
Last edited by DavidRegev on March 17th, 2012, 3:38 pm, edited 41 times in total.

Alice0775

User avatar
 
Posts: 2577
Joined: October 26th, 2007, 11:25 pm
Location: OSAKA JPN

Post Posted May 2nd, 2009, 5:17 pm

Workaround for
1. Bug 487263 - dragging a tab up or over the tab bar then out of the window does not detach
2. Bug 489729 - Clicking a tab once and then moving your mouse in a downward motion causes a new window to open.

Code: Select all
// ==UserScript==
// @name           patchForBug487263_489729.uc.js
// @namespace      http://space.geocities.yahoo.co.jp/gl/alice0775
// @description    Workaround for Bug 487263 - dragging a tab up or over the tab bar then out of the window does not detach & Bug 489729 - Clicking a tab once and then moving your mouse in a downward motion causes a new window to open.
// @include        main
// @compatibility  Firefox 3.5, 3.6a1pre
// @author         Alice0775
// @version        2009/05/19 19:00 For checking-in Bug 487263
// @version        2009/05/03 19:00 コンテンエリア判定
// @version        2009/05/02 19:00 ブラウザの外へのタブ分離と, センシビリティの改善
// ==/UserScript==
(function(){

  //xxxBug 489729
  // Timer which is used detaching tab.
  gBrowser.___onDragOverTimer = null;

  //xxxBug 489729
  // Detach of a tab is disabled immediately after dragstart.
  var func = gBrowser._onDragStart.toString();
    func = func.replace(
      'var target = aEvent.target;',
      <><![CDATA[
      var target = aEvent.target;
      if (gBrowser.___onDragOverTimer)
        clearTimeout(gBrowser.___onDragOverTimer);
      this.my_DragLeave = false;
      ]]></>
    )
    eval("gBrowser._onDragStart = " + func);

  //xxxBug 487263 & xxxBug489729
  gBrowser._onDragEnd = function _onDragEnd(aEvent) {
    var dt = aEvent.dataTransfer;
    if (dt.mozUserCancelled || dt.dropEffect != "none") {
        return;
    }
    var bo = this.mTabContainer.mTabstrip.boxObject;
    var tabbarEndScreenY = bo.screenY + bo.height;
    var screenX = aEvent.screenX;
    var screenY = aEvent.screenY;
    var box = gBrowser.mPanelContainer.boxObject;
    if (this.my_DragLeave &&
        box.screenY < screenY &&
        screenY < box.screenY + box.height &&
        box.screenX < screenX && screenX < box.screenX + box.width ||
        screenY < window.screenY ||
        window.screenY + window.outerHeight < screenY ||
        screenX < window.screenX ||
        window.screenX + window.outerWidth < screenX) {
        var draggedTab = dt.mozGetDataAt(TAB_DROP_TYPE, 0);
        this.replaceTabWithWindow(draggedTab);
    }
    aEvent.stopPropagation();
  }


  // xxxBug 489729
  // After drug over is carried out in contents area,
  // detaching of a tab is made enable in 100msec again.
  gBrowser.___onDragOver = function(aEvent) {
    if (!gBrowser.my_DragLeave) {
      gBrowser.___onDragOverTimer = setTimeout(function(self){
        self.my_DragLeave = true;
      }, 100, gBrowser);
    }
  }

  gBrowser.mPanelContainer.addEventListener('dragover', gBrowser.___onDragOver, true);
})();
Last edited by Alice0775 on May 19th, 2009, 12:10 am, edited 1 time in total.

Cye3s
 
Posts: 17
Joined: December 28th, 2007, 9:53 pm

Post Posted May 8th, 2009, 5:24 am

Hi,this code works only in the bookmarks-menu and in the personal bookmarks-toolbar,but not in the sidebar.And i don`t use "Sub-Script/Overlay Loader v3.0" ](*,)
I think "userChrome.import("*", "UChrm");" in userChrome.js is better :roll:
Code: Select all
var mItemPlace = document.createElement("menuitem");
      mItemPlace.setAttribute("id", "placesContext-test");
      mItemPlace.setAttribute("label", "Tets");
      mItemPlace.setAttribute("accesskey", "U");
      mItemPlace.setAttribute("oncommand", "alert('Test');");
      mItemPlace.setAttribute("selection","link");
      mItemPlace.setAttribute("selectiontype","single");
document.getElementById("placesContext").insertBefore(mItemPlace,document.getElementById("placesContext_open:newtab"));

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

Post Posted May 10th, 2009, 9:08 am

Cye3s wrote:Hi,this code works only in the bookmarks-menu and in the personal bookmarks-toolbar,but not in the sidebar.


you need to do something like this for sidebar in your userChrome.js:
Code: Select all
 function onLoadSidebar() {
  var document = this.contentDocument;
  if (!document.location || document.location.protocol != "chrome:")
    return;

  <your code>

  // Log it
  userChrome.log("onLoadSidebar", "myscript.js");
};

var sidebar = document.getElementById("sidebar");
if (sidebar)
  sidebar.addEventListener("load", onLoadSidebar, true);

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

Post Posted May 10th, 2009, 6:27 pm

some best practice advice needed - i currently have this in userChromeJS:

Code: Select all
if (typeof Cc == "undefined")
  var Cc = Components.classes;

however, anything (View -> Page Source, open SQLite Manager) that defines a const Cc will throw just due to the evaluation of var Cc. the best i can come up with is this:
Code: Select all
if (typeof Cc == "undefined")
  (function () {Cc = Components.classes;})();

but this will give a strict js warning 'assignment to undeclared variable' and i don't like anything in console. note that i can't have a var Cc in the function as it will only be a local var and unknown later on. anyone have any tricks here?

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

Post Posted May 10th, 2009, 11:26 pm

it seems the solution is:
Code: Select all
if (typeof Cc == "undefined")
  eval("var Cc = Components.classes");

and this specific case is pretty much the only unavoidable/legit use of eval()..

neologix

User avatar
 
Posts: 3
Joined: May 23rd, 2009, 10:33 pm
Location: New York, NY, USA

Post Posted May 23rd, 2009, 10:36 pm

hi there. i just updated my mac firefox 3.0.10 userchromejs from 1.0 to 1.1 and it neither displays as "just updated" or even installed. it's as if it was uninstalled completely! pls help!

diio
 
Posts: 14
Joined: April 30th, 2009, 9:37 am

Post Posted May 24th, 2009, 4:09 pm

neologix wrote:hi there. i just updated my mac firefox 3.0.10 userchromejs from 1.0 to 1.1 and it neither displays as "just updated" or even installed. it's as if it was uninstalled completely! pls help!


The same happened to me on a PC it got uninstalled but not updated. To fix it I had to close all firefox windows, reinstall 1.0 and update again... hope it helps

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

Post Posted May 24th, 2009, 5:29 pm

yes, there was a problem updating to v1.1 and it seems various mirrors may have had bad install.rdf files. the current v1.1 xpi on the homepage should work and install fine. however, there is still an open issue with mozdev regarding the path to update.rdf (for future auto updates).

apologies for the troubles.. i'll post a final resolution.

neologix

User avatar
 
Posts: 3
Joined: May 23rd, 2009, 10:33 pm
Location: New York, NY, USA

Post Posted May 29th, 2009, 12:34 am

so far, the only way for me to get this is to keep clicking the download link until a proper mirror is referenced, but i got it!

in the mean time, i have a question. i have the real-time tab preview uc js and i want to change the yellow box's style (eg, round corners, change color, font, etc). what is the element/node i need to access so i can apply the style change?

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

Post Posted May 29th, 2009, 2:00 pm

the real problem was that mozdev wasn't clearing the mirrors cache unless the file size had changed (in between the good/bad update paths variations of v1.1 it didn't) but they've fixed this and everything should be fine going forward.

as for the tab, perhaps better to ask piro on his site, or use DOMi to inspect the elements (i personally don't use it).

neologix

User avatar
 
Posts: 3
Joined: May 23rd, 2009, 10:33 pm
Location: New York, NY, USA

Post Posted May 29th, 2009, 6:24 pm

i use firebug and it doesn't access the tab preview nodes. i'll contact piro soon, thanks!

deskareas
 
Posts: 85
Joined: June 1st, 2003, 4:45 pm

Post Posted May 31st, 2009, 1:47 pm

please show me an example how to make a sub folder for my context menu scripts.

Jean-Gildas
 
Posts: 2
Joined: June 2nd, 2009, 10:02 am

Post Posted June 2nd, 2009, 10:14 am

Hey, I've just discovered this extension, and tested it by giving cookie description back to the firefox, after a lot of tests I've aimed at this :

Code: Select all
var intvCookies;

clearIntvCookies=function() {
 clearInterval(intvCookies)
}

intvCookies=setInterval(
 function() {
  if (document.getElementById("cookiesGroup")) {
   var description = document.createElement("description");
   description.appendChild(document.createTextNode("Cookies are delicious delicacies."));
   document.getElementById("cookiesGroup").insertBefore(description,document.getElementById("cookiesBox"));
   clearIntvCookies();
  }
 },
 0
);


But there's certainly a simplier way to do, and without setting an interval (here, using only the code in the function the interval calls makes the text disappear when you open Preferences windows on another tab than Privacy one), if anyone can give me a clue, I'll be grateful ^^

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 2 guests