Important: My version is not compatible with Nic’s or (likely) anyone else’s. If you’ve already made passwords with someone else’s tool, you should stick with it or recreate all your passwords. If you’re new to this, though, you’re fine.
Thanks to Nic for the original version. Thanks also to Tim Cuthbertson for pointing out that this tool originally did not take into account second-tier top-level domains like “co.uk” or “eu.com.” It now does, although the implementation is not perfect. Basically, it checks against a hardcoded list of known (to me) second-tier top-level domains. That list is here.