User:Kevin SF/category-stats.js

/* jshint esversion: 8, esnext: false */ console.log("Loaded category-stats.js"); // Show link to the "Massviews Analysis" on category pages if (mw.config.get("wgCanonicalNamespace") === "Category" && mw.config.get("wgAction") === "view") {	let initPromises = [ mw.loader.using('mediawiki.util'), new Promise((resolve) => {           if (document.readyState === "complete")            {                return resolve;            }            window.addEventListener("load",  => resolve);            document.addEventListener("DOMContentLoaded",  => resolve);        }) ];   Promise.allSettled(initPromises).then( => {        let baseMassviewLink = "https://pageviews.wmcloud.org/massviews/?platform=all-access&agent=user&source=category&range=latest-60&subjectpage=0&subcategories=1";        mw.util.addPortletLink( 'p-cactions', // portletId baseMassviewLink.concat(`&target=${location.href}`), // href 'Category Stats', // Text 'ca-category-page-statistics', // element id           'Shows pages in this category with statistics, such as view counts', // Tooltip text null, // keyboard shortcut key // 'nextnode' // Element to be added in front of       );    }); }