Well, a full plug-in and a re-configuration of the layout would be needed to add this functionality in full.
A script is run only when you press a button, so a script could be created that would let the user select a color and then counted how many pixels in the current layer have this color and then a message box with the number would pop up.
Perhaps if I understood what problem are you trying to solve, I could suggest a simpler solution.