My site Freesslproxy.com. does this too. If you visit Vtunnel threw freesslproxy you see its ads replaced with Mate1 ads. The only way to do it, is to learn programming of the language the script is written in. Thats how I did it. Sorry I cant be of much help but having such features are competitive advantage, I'm not going to give out my code.