Hi! I grew up in Peabody, which is the town next to Salem, and I lived in Salem for 3 years; it's the "thing to do" when you get your first apartment! I've never been to/heard of the Witch Dungeon Museum, so can't help you with that OR the Trolley, but I'd think the website (or tripadvisor.com) could give you some info. I can spend most of a day at the Peabody Essex Museum, but I'd plan at least an afternoon. The Salem Witch Museum is a presentation- an hour will probably do it. I'd say maybe an hour to an hour and a half at the Witch House; same with the Gables. I haven't been to either of them in about a decade, but I'd guess that should do it. You also should consider wandering around Derby Street while you are at the Gables; there are some historical buildings there associated with the waterfront, and there used to be a ship moored at the waterfront that you could tour (but I'm not sure it's still there).
And I agree with mtemm... Salem's not really what it used to be. I'd say a half-day for the Peabody Essex Museum and you could do all the other stuff in one day.