mw.loader.load('https://de.wikipedia.org/w/index.php?title=user:GFHund/monobook.js&action=raw&ctype=text/javascript');

/* test */
function linkingviaVIAF() {
/* goal / future  var targetURL = "http://librarything.com/author/viaf/viaf.org"; */

/* today */
  var targetURL = "http://yi.librarything.com/commonknowledge/search.php?f=13&exact=1&q=VIAF%3Aviaf.org";
 
  var magicRegex = /viaf.org/ig;
 
  for (var i = 0; i < document.links.length; i++)
  {
    if( document.links.href.match(/viaf.org\/(.*)/) )
    {
/*    document.links.href=targetURL.replace(magicRegex, RegExp.$1); */
      document.links.href=targetURL.replace(magicRegex, RegExp.$1.replace(/*/g, ''))
    }
  }
}
 
$(linkingviaVIAF);

/* Example for ] -- ] */

$ ( function() { if (wgArticleId) mw.util.addPortletLink("p-tb", wgScript + "?curid=" + wgArticleId, "Short url", "t-curid", "Reference using its article id"); } );