User:Fenakhay/scripts/nonmainspaceCategories.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.


/*
	Cleans up categories for reconstructed and appendix-only languages.
	Removes "Reconstructed:Langname/" or "Appendix:Langname/" from the beginnings of links
	in the list of entries and the lists of recently added
	and oldest entries, replacing it with an asterisk,
	so that the links look like they would in an entry.
*/

var namespaceNumber	= mw.config.values.wgNamespaceNumber;

/*
	If in Category namespace, and if there's a catfix, indicating
	that the category belongs to a reconstructed or appendix-only language.
*/
if ( namespaceNumber === 14 && $("#catfix").length )
{
	$(".mw-category, #recent-additions, #oldest-pages").find("a").html(
		function(index, content)
		{
			return content.replace(
				/Reconstruction:[^\/]+\//g,
				"*"
			);
		}
	);
	$(".mw-category, #recent-additions, #oldest-pages").find("a").html(
		function(index, content)
		{
			return content.replace(
				/Appendix:[^\/]+\//g,
				""
			);
		}
	);
}