right click open in new tab takes you to the original link. So this must be done in session or something and the alt-open in next tab take the plain link URL?
By doing right-click and "Open link in new tab", there's no actual onclick event, as what you're actually doing is opening the original link in a new tab. Therefore, his href replacing code wouldn't get executed.