How to execute python code before blender operator is executed
I don't think that there are listeners which you can use in that way. 

But what you can do is your idea in the second question. You could replace the button with a custom operator which executes your code first and calls the original operator afterwards.
You can access the sources if you right-click on that original button and choose edit source. After that go to the scripting view and choose the source file available in the dropdown box