User:Jeblad/hide references/script.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.
// Code to show references hidden by styling
// © John Erling Blad, Creative Commons by Attribution 3.0
mw.loader.using( ['mediawiki.util'], function () {
$(function() {
"use strict";
var conf = mw.config.get([
'wgNamespaceNumber',
'wgAction'
]);
if (conf.wgNamespaceNumber !== 0) {
mw.util.$content.addClass('mw-show-references');
return;
}
if ( conf.wgAction !== "view" ) {
mw.util.$content.addClass('mw-show-references');
return;
}
mw.hook( 'wikipage.content' ).add(function( $content ) {
var addClass = function() {
mw.util.$content.addClass('mw-show-references');
};
var $links = mw.util.$content.find('.references').children('li').find(':first-child > a');
$links.click(addClass);
});
});
});