It clusters the colors using Kohonen neural networks (which always makes me giggle, because "Kohonen" sounds like a Spanish swear word). The source for it all is here: https://github.com/unindented/palette-creator
Unrelated: Every week I receive an offer to "monetize" my extension from the shadiest companies all over the world. I'm guessing they'd add all kinds of tracking to it, make it inject ads and fake results into the pages the user is viewing, etc. So yeah, be careful who you trust when it comes to browser extensions!
Right now I am using the RgbQuant library (https://www.npmjs.com/package/rgbquant), but I've been experimenting with neuqant-js as well. The Chrome extension you've mentioned before is really great!