Technically speaking you will only void the warranty if you damage your laptop during the surgery. The warranty is very specific in that it does not state that you cannot open the computer but rather if a non authorized persons performance upgrades/maintenance and damages it will the warranty be voided for the damaged parts.
With that said, if you replace the battery yourself and use one that isn't the same one that apple uses, or that there's evidence of your surgery, they'll know.
Personally, I avoid opening up laptops that are within the warranty because generally the risk is not worth the reward, if someone is going to break/damage the computer, I'd rather have apple do it (so they can repair that w/o any expense to me).