User:Xover/Gadget-sandbox.js

function tabulateResults { let groups = {}; $(".mw-search-result-heading a").each((i, e) => {		let page = $(e).attr("title");		let index = page.replace(/^Page:(.*)\/\d+/, '$1');		if (groups[index] === undefined) {			groups[index] = 1;		} else {			groups[index] += 1;		}	}); for (const g in groups) { console.log(g + ": " + groups[g]); } } $(function {    var countPortlet = mw.util.addPortletLink( 'p-cactions', '#', 'Count results', 'ca-count', 'Count the search results by index' );    $(countPortlet).on('click', function (e) { e.preventDefault; tabulateResults; }); });