User:Gary/custom long pages.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Gary/custom long pages. |
/*
CUSTOM LONG PAGES
Description: Adds options for [[Special:LongPages]], such as the ability to hide articles that begin with "List of".
*/
if (typeof(unsafeWindow) != 'undefined')
{
mw = unsafeWindow.mw;
}
$(customLongPages);
function customLongPages()
{
var jumpToNav = $('#jump-to-nav');
if (mw.config.get('wgPageName') != 'Special:LongPages' || !jumpToNav.length) return false;
var newNode = $('<p><b>Options:</b> <a href="' + location.href.replace('hide=lists', '') + '">Show</a> / <a href="' + location.href + (location.href.indexOf('?') != -1 ? '&hide=lists' : '?hide=lists') + '">hide lists</a></p>');
jumpToNav.after(newNode);
if (location.href.indexOf('hide=lists') == -1) return false;
var hiddenArticles = 0;
$('.special').eq(0).children().each(function()
{
var article = $(this);
if (article[0].nodeType != 1) return true;
if (article.children().eq(1).text().indexOf('List of') == 0)
{
article.css('display', 'none');
hiddenArticles++;
}
});
$('.mw-spcontent').eq(0).children().first().children().first().append('<span id="hidden-articles"> (' + hiddenArticles + ' hidden' + ')</span>');
}