Sounds like a job for #scripting. You could hide the existing button, and create a new button that handles the logic that you're after, and then have that button call the hidden button. Unless I'm forgetting something, and after the morning I've had, I probably am.