Use temp dir instead of profile dir
Re-written for Firefox 27+
Refactored
Re-written for Firefox 27+