That seems like a giant pain in the butt.  Could something from http://work.erikvold.com/pathfinder/2013/06/26/introducing-addon-pathfinder.html help out here?  Or, could you just poke the styles on the element itself?  Or if you don't feel like either of those, what do you think about pulling these out into a xul-stylesheet library that can be used from other places?