second The toolbox plugin. (also for Sigil)
BUT it removes a specified tag , by a specified criteria.
eg
remove a span that has no attribute (naked).
Modify span class="slanty" and make it <i> (optionally keep the attribute)
But it is not intelligent.
You need to understand WHY the code IS the way it is. (your example is extreme.
The Editor has a CSS clean function that combines all the identical CSS entries (but does not change the code in the book)

What I do is run the clean/combine. Then use the toolbox to reduce the combined items to 1 selector ( a bit tedious, but fairly quick each pass)