Rated 2 out of 5 stars

Hi,
With the Custom buttons extension , simply add a button with the code :

var acctMgr = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager);
var accounts = acctMgr.accounts;
for (var i = 0; i < accounts.Count(); i++) {
var account = accounts.QueryElementAt(i, Components.interfaces.nsIMsgAccount);
var rootFolder = account.incomingServer.rootFolder; // nsIMsgFolder
if (rootFolder.hasSubFolders)
{
var subFolders = rootFolder.subFolders; // nsIMsgFolder
while(subFolders.hasMoreElements())
{
var folder = subFolders.getNext().QueryInterface(Components.interfaces.nsIMsgFolder);
if( folder.flags & 0x0100 ) try { folder.emptyTrash(null, null); } catch(ex) {}
}
}
}
goDoCommand('cmd_compactFolder');

in it.