Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * doRedirect will redirect if a did you mean box is found
  3.  * Taken from https://en.wiktionary.org/w/index.php?title=MediaWiki:Common.js&oldid=17219894
  4.  * Altered by [[m:User:Hoo man]]
  5. **/
  6.  
  7. $(document).ready(function() {
  8.     if( window.location.href.indexOf('rdfrom=') === -1 ) {
  9.         var target = jQuery('#did-you-mean a').html(),
  10.             pagetitle = jQuery('h1').first().text().trim();
  11.  
  12.         if( target && target != pagetitle
  13.                    && !window.location.href.match(/[&\?]redirect=no|[&\?]action=(?!view)/)
  14.                    && wgArticleId === 0
  15.                    && !/Redirected from/.test(jQuery('#contentSub').html())) {
  16.             document.location = mw.util.wikiGetlink( target ) + '?rdfrom=' + mw.util.wikiUrlencode( pagetitle );
  17.         }
  18.     }
  19. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement