[Ext] userChrome.js

Announce and Discuss the Latest Theme and Extension Releases.
Locked
User avatar
aaron
Posts: 3130
Joined: November 4th, 2002, 8:49 pm
Location: Texas
Contact:

Post by aaron »

I tried that code with 1.5.06 and no luck.
Zoolcar9
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)
Contact:

Post by Zoolcar9 »


For Firefox 1.5.0.* users, try this

Code: Select all

var searchbarAutoclear = {
  init: function() {
    this.searchbar = document.getElementById("searchbar");
    this.searchbarTextbox = this.searchbar.mTextbox;
    this.searchbarTextbox.addEventListener("keypress", function(event) { searchbarAutoclear.clear(event); }, false);
  },

  clear: function(event) {
    if (event.keyCode == 13) {
      setTimeout("searchbarAutoclear.searchbar.value='';", 0);
      setTimeout("searchbarAutoclear.searchbarTextbox.value='';", 0);
      event.stopPropagation();
    }
  }
};

searchbarAutoclear.init();

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."
User avatar
Ria
Posts: 3550
Joined: March 21st, 2004, 3:25 am
Location: Netherlands

Post by Ria »

Zoolcar9 wrote:
What version of Firefox are you using?



Trunk usually.
Zoolcar9
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)
Contact:

Post by Zoolcar9 »


For trunk users, try

remove

Code: Select all

var button = document.getAnonymousElementByAttribute(searchGoButton, "anonid", "button");

and

replace

Code: Select all

button.addEventListener(" ...


with

Code: Select all

searchGoButton.addEventListener(" ...

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."
max1million
Posts: 2810
Joined: November 15th, 2004, 5:03 am

Post by max1million »

Diorser That code just gets the exe and sits there waiting to be told what to do with it.Last line: file.launch();
is what says to execute it.

You can use previouly mentioned code to open Firefox with a proper URL like file:///C:/page.html it would be the same effect as opening the C: drive and clicking on page.html (if Firefox is your default). If you just want to load a new URL, file:/// and http:// are just a couple Firefox understands you can use:

Code: Select all

var url = "file:///C:/page.html" 
loadURI(url);
To load a URL in a new tab:

Code: Select all

var url = "file:///C:/page.html"
gBrowser.addTab(url);
To load a URL in a new tab and make sure it is selected:

Code: Select all

var url = "file:///C:/page.html"
var newTab = gBrowser.addTab(url);
gBrowser.selectedTab = newTab;


forgot my "
Last edited by max1million on September 2nd, 2006, 4:56 pm, edited 1 time in total.
User avatar
Ria
Posts: 3550
Joined: March 21st, 2004, 3:25 am
Location: Netherlands

Post by Ria »

OK Zoolcar9, thanks, it's working now. It clears the searchbar after clicking Go or hitting Enter, and I still believe it's the same what it did when I tried it earlier some days ago.
Yesterday I added another snippet "Auto context menu" and suddenly I got a slow script warning and the whole extension stopped working. When I removed the last added snippet everything worked again, except that "Auto clear searchbar" thing. I tried the "Auto context menu" in a new profile as the only snippet, and then it worked :?.
Finally I removed "Auto context menu" because it conflicted with my other habits.
Mysteries, mysteries :). Well, I'll try not to think about it anymore :).
User avatar
Diorser
Posts: 1009
Joined: June 22nd, 2005, 6:57 am

Post by Diorser »

@max1million

Adaptation of metapad.xpi to PsPad works perfectly.
However, I still don't understand the concept of the extension creation which is unbelievably complex with the rdf files.
I've just tune the files after installation and it's ok.

I have added a menu icon in metapadOverlay.xul
<popup>
<menuitem
id="metapad-do-view"
image="chrome://metapad/content/PSPad.png"


And I have changed metapad.tmp by pspad.htm so the the right tag highlighting of the editor is detected with the htm extension.

For the file:///C:/page.html story, you gave me everything to go ahead.

Thanks again for all.
User avatar
Diorser
Posts: 1009
Joined: June 22nd, 2005, 6:57 am

Post by Diorser »

Is there a way to add a IE icon to the menu line of this script ? (the icon is not the problem but the element to address).

<li> <a href="data:text/javascript,%2F*%20%3A%3A%3A%3A%3A%3A%3A%3A%20LaunchIE%20(cf.%20IE%20View)%20%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%20*%2F%0A%0Avar%20LaunchIE%20%3D%20%7B%0A%09mSchemes%3A%20%5B%22file%22%2C%20%22ftp%22%2C%20%22http%22%2C%20%22https%22%5D%2C%0A%0A%09init%3A%20function()%0A%09%7B%0A%09%09this.mItem%20%3D%20document.createElement(%22menuitem%22)%3B%0A%09%09this.mItem.setAttribute(%22label%22%2C%20%22LaunchIE%22)%3B%0A%09%09this.mItem.setAttribute(%22accesskey%22%2C%20%22u%22)%3B%0A%09%09%0A%09%09document.getElementById(%22contentAreaContextMenu%22).addEventListener(%22popupshowing%22%2C%20function()%20%7B%20LaunchIE.onPopupShowing(this)%3B%20%7D%2C%20false)%3B%0A%09%7D%2C%0A%0A%09onPopupShowing%3A%20function(aPopup)%0A%09%7B%0A%09%09aPopup.insertBefore(this.mItem%2C%20document.getElementById(%22context-sep-%22%20%2B%20((gContextMenu.onLink)%3F%22open%22%3A%22stop%22)))%3B%0A%09%09this.mItem.setAttribute(%22oncommand%22%2C%20%22LaunchIE.launch(%22%20%2B%20((gContextMenu.onLink)%3F%22gContextMenu.linkURI%22%3A%22gBrowser.currentURI%22)%20%2B%20%22)%3B%22)%3B%0A%09%09this.mItem.hidden%20%3D%20!gContextMenu.onLink%20%26%26%20(gContextMenu.isTextSelected%20%7C%7C%20gContextMenu.onImage%20%7C%7C%20gContextMenu.onTextInput)%3B%0A%09%09this.mItem.setAttribute(%22disabled%22%2C%20this.mItem.hidden%20%7C%7C%20!this.isSupported((gContextMenu.onLink)%3FgContextMenu.linkURI%3AgBrowser.currentURI))%3B%0A%09%7D%2C%0A%0A%09launch%3A%20function(aURI%2C%20aApp)%0A%09%7B%0A%09%09if%20(!this.isSupported(aURI))%0A%09%09%7B%0A%09%09%09throw%20new%20Error(%22LaunchIE%3A%20unsupported%20URI%20scheme%20'%22%20%2B%20aURI.scheme%20%2B%20%22'!%22)%3B%0A%09%09%7D%0A%09%09%0A%09%09var%20iexplore%20%3D%20Components.classes%5B%22%40mozilla.org%2Ffile%2Flocal%3B1%22%5D.createInstance(Components.interfaces.nsILocalFile)%3B%0A%09%09try%0A%09%09%7B%0A%09%09%09var%20regkey%20%3D%20Components.classes%5B%22%40mozilla.org%2Fwindows-registry-key%3B1%22%5D.createInstance(Components.interfaces.nsIWindowsRegKey)%3B%0A%09%09%09regkey.open(Components.interfaces.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE%2C%20%22SOFTWARE%5C%5CMicrosoft%5C%5CWindows%5C%5CCurrentVersion%5C%5CApp%20Paths%5C%5C%22%20%2B%20(aApp%20%7C%7C%20%22IEXPLORE.EXE%22)%2C%20Components.interfaces.nsIWindowsRegKey.ACCESS_READ)%3B%0A%09%09%09iexplore.initWithPath(regkey.readStringValue(%22%22))%3B%0A%09%09%09regkey.close()%3B%0A%09%09%7D%0A%09%09catch%20(ex)%0A%09%09%7B%0A%09%09%09iexplore.initWithPath((Components.classes%5B%22%40mozilla.org%2Fprocess%2Fenvironment%3B1%22%5D.getService(Components.interfaces.nsIEnvironment).get(%22PROGRAMFILES%22)%20%7C%7C%20%22C%3A%5C%5CProgram%20Files%22)%20%2B%20%22%5C%5CInternet%20Explorer%5C%5Ciexplore.exe%22)%3B%0A%09%09%7D%0A%09%09%0A%09%09var%20process%20%3D%20Components.classes%5B%22%40mozilla.org%2Fprocess%2Futil%3B1%22%5D.createInstance(Components.interfaces.nsIProcess)%3B%0A%09%09process.init(iexplore)%3B%0A%09%09process.run(false%2C%20%5BaURI.spec%5D%2C%201)%3B%0A%09%7D%2C%0A%0A%09isSupported%3A%20function(aURI)%0A%09%7B%0A%09%09return%20this.mSchemes.indexOf(aURI.scheme)%20%3E%20-1%3B%0A%09%7D%0A%7D%3B%0A%0ALaunchIE.init()%3B%0A">LaunchIE</a> (IEView without UI)

I've tried to add a line like this.style.listStyleImage = "url(data:image/x-icon;base64,xyz.......)" with no success.

.... not sure "this.style.listStyleImage" is the right element to address.

Thanks.
Zoolcar9
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)
Contact:

Post by Zoolcar9 »

Code: Select all

this.mItem = document.createElement("menuitem");
this.mItem.setAttribute("label", "LaunchIE");
this.mItem.setAttribute("accesskey", "u");
this.mItem.className = "menuitem-iconic";                 //add
this.mItem.style.listStyleImage = "url(data:....)";       //these
document.getElementById("contentAreaContextMenu")........

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."
max1million
Posts: 2810
Joined: November 15th, 2004, 5:03 am

Post by max1million »

@Diorser
By the way, if you going to reuse code you should change function names, id and such. "Replace all" metapad with something else (uniquename) in all the files, file and folder names.
User avatar
Diorser
Posts: 1009
Joined: June 22nd, 2005, 6:57 am

Post by Diorser »

@Zoolcar9
Thanks, it works, the proof : Image
However image/x-icon did not work; only image/x-icon;base64 is OK.

BTW, is there a simple tool or JavaScript to convert a picture in data:image ?
I only found http://software.hixie.ch/utilities/cgi/data/data to make the conversion.


@max1million
Each time I try to tweak an extension, I get a headache.
These extensions are a real nightmare to modify (I even don't say to create).
I don't understand why such a complexity is necessary for such simple expected results.

I then have only modified metapad extension AFTER installation in extension dir.
I did not try to repack the xpi.
I tried to modify ALL occurrences of metapad word in ALL files, but even with a real care by cleaning extensions.rdf + extensions.ini + extensions.cache: Firefox does not recognize anything.
I should have said I tried to remove all files I thought unnecessary.

Then, now it works, it's OK, although I know I will get in trouble next time I will have to refresh my profile.

So, I wonder if by using userchrome.js, it is possible to launch "edit with PsPad (or metapad)" based on metapad extension, by tweaking only metapadOverlay.js + metapadOverlay.xul (+ metapad.dtd which is may be optional).

I tried, but once more... no success.
Sure it is so easy when you know JavaScript, xul, xml etc... but not interested to invest time on this.
If you have any idea, you're welcome !
Old Greg S
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by Old Greg S »

Anyone know if it's possible to use the system sounds I have set for menupopup and then the clicking of a menuitem?
Zoolcar9
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)
Contact:

Post by Zoolcar9 »


New userChrome.js scripts/xul:
  • <a class="postlink" href="data:application/x-javascript;base64,V2luZG93SG9vay5yZWdpc3RlcigiY2hyb21lOi8vYnJvd3Nlci9jb250ZW50L3ByZWZlcmVuY2VzL3ByZWZlcmVuY2VzLnh1bCIsCiAgZnVuY3Rpb24oYVdpbmRvdykgewogICAgZnVuY3Rpb24gYWRkQnV0dG9uKCkgewogICAgICB2YXIgZGxHcm91cCA9IGFXaW5kb3cuZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoImRvd25sb2Fkc0dyb3VwIik7CiAgICAgIGlmKCFkbEdyb3VwKSByZXR1cm47CiAgICAgIHZhciBidXR0b24gPSBhV2luZG93LmRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImJ1dHRvbiIpOwogICAgICBidXR0b24uc2V0QXR0cmlidXRlKCJsYWJlbCIsICJWaWV3ICYgRWRpdCBEb3dubG9hZCBBY3Rpb25zLi4uIik7CiAgICAgIGJ1dHRvbi5zZXRBdHRyaWJ1dGUoIm9uY29tbWFuZCIsCiAgICAgICAgImRvY3VtZW50LmRvY3VtZW50RWxlbWVudC5vcGVuV2luZG93KCIgKwogICAgICAgICInUHJlZmVyZW5jZXM6RG93bmxvYWRBY3Rpb25zJywgIiArCiAgICAgICAgIidjaHJvbWU6Ly9icm93c2VyL2NvbnRlbnQvcHJlZmVyZW5jZXMvZG93bmxvYWRhY3Rpb25zLnh1bCcsICIgKwogICAgICAgICInJywgbnVsbCk7Iik7CiAgICAgIGRsR3JvdXAuYXBwZW5kQ2hpbGQoYnV0dG9uKTsKICAgIH0KICAgIGFkZEJ1dHRvbigpOwogICAgYVdpbmRvdy5kb2N1bWVudC5nZXRFbGVtZW50QnlJZCgicGFuZU1haW4iKQogICAgICAuYWRkRXZlbnRMaXN0ZW5lcigicGFuZWxvYWQiLCBhZGRCdXR0b24sIGZhbHNlKTsKICAgIGFXaW5kb3cuZG9jdW1lbnQuZG9jdW1lbnRFbGVtZW50LnN0eWxlLmhlaWdodCA9ICI0M2VtIjsKICB9Cik7">Adds "View & Edit Download Actions..." button</a> on Firefox 2.0b2 Pref dialog (screenshot).
    Requires WindowHook snippet.
  • Inspect Window.js/<a class="postlink" href="view-source:http://zoolcar9.lhukie.net/mozilla/userChromeJS/xul/inspectWindow.xul">inspectWindow.xul</a>
    Adds Tools -> Inspect a Window menu to inspect an opened chrome window (screenshot)
  • <a class="postlink" href="view-source:http://zoolcar9.lhukie.net/mozilla/userChromeJS/xul/shortenLink.xul">shortenLink.xul</a>
    Adds "Shorten This Link" menu to context menu.

Updated scripts:
Last edited by Zoolcar9 on September 6th, 2006, 10:08 pm, edited 2 times in total.
My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."
User avatar
Schrade
Posts: 1187
Joined: March 17th, 2004, 12:24 am

Post by Schrade »

Zoolcar9, I get a messed up options window when I do the View & Edit Download Actions button:
<img src="http://i2.tinypic.com/4h9emqc.png" width="469" height="466">

I'm using the default system font size, so that's not the issue.
"Linux is for those who hate Windows, BSD is for those who love Unix." -Some Guy
Try my themes: QuBranch and QuTrunk
Fix Firefox's Resized image scrolling speed: <b>Bug 163975</b>
Zoolcar9
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)
Contact:

Post by Zoolcar9 »


Sorry.. I forgot I'm using a customized Options dialog. For the moment, add this line to your userChrome.js to make your Options dialog resizable

Code: Select all

eval("openPreferences = " + openPreferences.toString().replace(/\(instantApply\s\?\s\"\,dialog\=no\"\s\:\s\"\,modal\"\)/, "\",resizable,minimizable\""))

I'll try to fix the button later.

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."
Locked