MediaWiki

Gadget-pagecount.js

From Dogcraft Wiki

Revision as of 21:38, 1 February 2023 by Domino (talk | contribs)

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.
$( function () {
	var pagecount = document.createElement('div'),
		link = document.createElement('a'),
		pages = document.createElement('span'),
		text = document.createElement('span'),
		actions = document.getElementById('wikiActions'),
		api = new mw.Api(),
		num = api.get( {
			action:"query",
			meta:"siteinfo",
			siprop:"statistics",
			formatversion:"2"
		} );
	
	pagecount.id = 'pagecount';
	link.href = "/wiki/Special:AllPages?namespace=0&hideredirects=1";
	text.textContent = 'pages';
	
	$.when( num ).then( function ( data ) {
		pages.textContent = data.query.statistics.articles;
		link.append(pages, text);
		pagecount.append(link);
	
		actions.parentNode.insertBefore(pagecount, actions);
	});
	
	mw.hook( 'userjs.pagecount.done' ).fire();
	
	mw.hook( 'userjs.pagecount.done' ).add( function() {
	if (mw.config.get('wgNamespaceNumber') === 3004) {
		$("#pagecount").append($(".mw-indicators.mw-body-content")); 
	}
});
});
This page was last modified on 1 February 2023, at 21:38. (13 months ago)