MediaWiki:Gadget-HashRedirect.js
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: hold down Ctrl and click the Refresh or Reload button. Firefox: hold down ⇧ Shift while clicking Reload (or press Ctrl+⇧ Shift+R). Google Chrome and Safari users can just click the Reload button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/**
* <nowiki>
* Usage via {{Hash redirect}}.
* Redirects pages with # in the URL to the respective page.
* Original code by Deltaneos.
* Adapted as gadget by Becasita.
* @author Deltaneos
* </nowiki>
*/
( function _gadgetHashRedirect( window, document, $, console ) {
"use strict";
var LAST_LOG = '19:45, 23 August 2018 (UTC)';
if ($('.hash_redirect')) {
var redirects = document.getElementsByClassName('hash_redirect');
var hash = window.location.hash.substring(1);
for (var k = 0; k < redirects.length; k++) {
if (redirects[k].getAttribute('data-value') === hash) {
window.location = window.location.href.replace('#', '_');
}
}
}
console.log( '[Gadget] HashRedirect last updated at', LAST_LOG );
} )( window, window.document, window.jQuery, window.console );