Jump to content

User:Dragons flight/monobook.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
function fixSecureLink() {
  if (mw.config.get('wgServer') == "https://secure.wikimedia.org") {    
    for( var k = 0; k < document.links.length; k++ ) {
      var link = document.links[k];
      if( link.href.indexOf('https://secure.wikimedia.org/wiki/') > -1 ) {
        var new_link = mw.config.get('wgServer') + mw.config.get('wgArticlePath');
        new_link = new_link.replace("$1","");
        link.href = link.href.replace('https://secure.wikimedia.org/wiki/',new_link);
      }
    }
  }
}

addOnloadHook( fixSecureLink );