Lestard's Blog Software-Development with JavaScript, XUL, Firefox-Addons, XML, Java…

28Jun/110

Hiding Toolbars for App-Tabs in Firefox

Some weeks ago I have written a little Addon for Firefox which lets you hide the toolbars for domains. This was mainly aimed at App-Tabs introduced in Firefox4. The Addon was working for me and some friends but sadly the people on Firefox's Addonsite obviously couldn't get it to work and so it wasn't hostet on there.

Today I have read a wikipage which stated that the Firefox developers are working on a similar functionality for a future release of Firefox. I think that's great because this feature is really usefull. In the past I haven't had enough time to fix bugs on my Addon and had an bad conscience about this. But now that they implement it on there own I feel all right to not support my Addon anymore because you will get the functionality by default. That's why I love Firefox. They put interesting features in the browser but you have the choice to use it or not.

10Apr/110

How it works: Hide Toolbars in Firefox 4

Last week I finished my HideToolbarsByURL extension. Now I want to explain a little bit how it works. Because I have used this technique in my other project I thought this could probably be usefull for other people as well.

Hide the Toolbar

In Firefox 4 there was a new Addon-Manager introduced which opens itself in a new tab. If you have set your tabbar to be on top of the navigation bar this addons-manager tab has no navigationbar or bookmarksbar. This is realized with the new function "hideChromeForLocation" of the XULBrowserWindow object. This function is called everytime a tab is shown e.g. when you open a new tab or you switch to another tab. This function gets the current Location (URL) of the tab as an argument of the type string. If this function returnes true for the location then the toolbars are hidden.

If you want to hide your URL too you have to override this function so it returns true for your location. But if you simply replace this function with your own, other extensions and firefox itself will not be able to use this feature. The recommended way to get your location hidden is to chain your implementation of this function with the original one.

First you save a reference of the original implementation. Then you can override the function with your own. You have to determine if the given location is your desired location and return true. Otherwise call the original implementation.

var old = XULBrowserWindow.hideChromeForLocation;
 
//override the hideChrome-funtion with our logic
XULBrowserWindow.hideChromeForLocation = function(aLocation){
 
	if(0 === aLocation.indexOf("http://www.lestard.eu")){
    		return true;
    	}
	//Call the original hideChrome-function
	return old.call(XULBrowserWindow,aLocation);
};

If the current location (aLocation) starts with "http://www.lestard.eu" then return true and hide the Toolbars. Otherwise call the old implementation with the aLocation as argument.

In my extension I put the URLs which should be hidden in an array. In my overridden hideChromeForLocation function I look if the current Location is in the array. Because I only want to check the first part of the URL (the domain) I use the nsIURI object from mozilla.

 

veröffentlicht unter: Firefox Extensions, General keine Kommentare
1Apr/110

Add-on submitted to AMO

I have finished my work on the "hide-toolbars-by-URL"-Extension and also submitted it to addons.mozilla.org (AMO). Now they review the addon and look if its properly working. Within the next days the review process should be finished and then the addon would be visible on the addons-page.

But you can use the addon anyway because it is already available on AMO but not visible in the search-results. So to use it you need the URL which is: https://addons.mozilla.org/de/firefox/addon/hide-toolbars-by-url/

Within the next days I want to write some lines on how the addon works so everybode how is interested in can use the code.

veröffentlicht unter: Firefox Extensions keine Kommentare
27Mrz/112

Hide Toolbars in Firefox 4

With the new Firefox 4 release mozilla has introduced some interesting new features and improvements. Particularly the changes to the GUI are interesting. Now you can pin a Tab as "App Tab" and so the tab is pinned on the left side of the tab-panel and you only see the favicon of this tab. I really like this for applications like google mail and google calender but also for news pages I regularly read.

But there are also problems with this approach. Sometimes I forget that I'm in an AppTab and that I don't want to switch to another page in this Tab. But because I have the URL-bar available it happens that I found another page in the Tab where my "App" should be.

Another issue is that the main goal of the AppTabs is saving space. To support this, wouldn't it be cool to hide the URL-bar and other toolbars when you are in an AppTab? You also couldn't change the location by accident. This is what I thought and so I begun to write a little extension to enable this.

Happily mozilla introduced a technique to do exactly this. When you open the new Addon-Manager you see that it is opened in a new tab. If you have set your tabpanel to be on top of the URL-bar you will see the toolbars hidden when you are inside of the Addon-Manager-tab. You can use this technique for every page you want ... at least on paper. Sadly there is no GUI with which you could enable hiding for a specified URL. This is what my extension is doing.

With my extension "Hide Toolbars by URL" you have a new entry in the context menu of every tab with which you can hide this URL. The hiding is connected to the URL, not to the tab. So if you open the same URL in another tab it will also be hidden. But because the exact URL will change when you use the page (i.e. when you follow a link on this domain you will be at another URL) it wouldn't be really cool. So only the first part of the URL is used to determine if the tab should be hidden. I only use "http://www.google.de" - everything behind is cut of. So every "subpage" of "http://www.google.de" will be hidden. I'm not sure if this approach is the bests so I would love to get feedback for this. Probably I will change this in the future.

Of cause the code is free and open source - you can get the code at github.com. There is also the xpi-file you need to install. I will give this extension to the addon-page of mozilla and probably they will add this to there page so you can easily install it the same way you install every extension.

veröffentlicht unter: Firefox Extensions, Software 2 Kommentare
   

WP SlimStat