Macro stops when open a new tab or open a URL

Nope, it is as designed. That innocuous line of JS was abused about a decade ago by intrusive ads.

Besides the fact that you used instead of ', this JS code has definitely trip your browser’s pop-up blocker which blocked the new tab and make it look like nothing is happening.

You could add an exception to your browser, perhaps? But do so to your discretion.