User:Taavi/Unslashifier.js: Difference between revisions

Content deleted Content added
m Superpes15 moved page User:Majavah/Unslashifier.js to User:Taavi/Unslashifier.js: Automatically moved page while renaming the user "Majavah" to "Taavi"
fix for html changes
 
Line 1:
/*
* Unslashifier by [[User:MajavahTaavi]] @ en.wikipedia.org
* A user script that redirects accidental navigation to 404's ending in a slash (say, Foo/) to the normal page (Foo)
*/
$( function() {
var pageName = mw.config.get( 'wgPageName' );
if ( pageName.endsWith('/') && document.querySelector('#p-namespaces '.selected.newpagetitlecorrection' ) ) {
var url = mw.util.getUrl( pageName.slice( 0, -1 ) );
window.___location.href = url;
}
} );