User:Ricordisamoa/SkipRedirect.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* <nowiki>
* SkipRedirect.js
*
* manipulates the browser's URL bar to show the 'correct' page name
* (only when viewing redirects)
* @author [[User:Ricordisamoa]]
* -- for recent browsers only --
*/
if ( typeof window.history.replaceState === 'function' ) {
$( function () {
if ( mw.config.get( 'wgAction' ) === 'view' && mw.config.get( 'wgIsArticle' ) === true ) {
var $redir = $( '#contentSub b a[href$="redirect=no"]' );
if ( $redir.length === 1 ) {
var redir = $redir.text(),
regex = new RegExp( $.escapeRE( mw.util.getUrl( redir ) ) + '$' );
if ( regex.test( window.location.href ) ) {
window.history.replaceState( {}, '', window.location.href.toString().replace( regex, mw.util.getUrl( mw.config.get( 'wgPageName' ) ) ) );
}
}
}
} );
}