How to detect when a user selects a material in the default Shapespark material picker palette?

There is no official way to do it, but as a workaround you can use the method described in Material Picker on which extension? - #3 by Clinton_James

To send information from the iframe to the parent webpage, and back, you can use the postMessage API, as explained in Configurator Commands - #10 by jan.