The problem here is that many links have an onClick handler already, and behind the scene turn a "new tab" link into a regular link. Meanwhile since this onClick handler finds a href that opens a new tab, it opens a new window. The old handler gets called too, but the result is a lot of new windows get opened that could have just reused the current window.
conclusion: this code works, and is an improvement but may be a dead end.