In Mediawiki 1.31 this does not work. Neither for internal nor for external links.
~~~~
In Mediawiki 1.31 this does not work. Neither for internal nor for external links.
~~~~
Works for me if I copy the code and execute it on the browser's JavaScript console, and then click on the link with that markup.
Maybe you put the code on the wrong place, or there are other JavaScript errors preventing this code from being executed.