what is an easy way to get the domain without the subdomain.
For example in this URL: http://a.b.hllo.co.uk
I want to retrieve hllo
You will want to use the nsIEffectiveTLDService for this. It's basically a giant list of special-cases maintained by mozilla such as the mentioned .co.uk
domain and used for same-basedomain (as opposed same-origin) policies such as cookies.
Some of its functionality is also exposed in the sdk/url module.