User:Taavi/Unslashifier.js: Difference between revisions

Content deleted Content added
quick and dirty user script
 
format in es5
Line 3:
* A user script that redirects accidental navigation to 404's ending in a slash (say, Foo/) to the normal page (Foo)
*/
$(function() {
(() => { // sandbox variables by wrapping inside a function
constvar pageName = mw.config.get('wgPageName');
if (pageName.endsWith('/') && document.querySelector('#p-namespaces .selected.new')) {
constvar url = mw.util.getUrl(pageName.slice(0, -1));
window.___location.href = url;
}
})();