User:Eejit43/scripts/to-monitor-list.js

// // Note: This script was compiled and minified from TypeScript. For a more readable version, see https://github.com/Eejit43/wikipedia-scripts/blob/main/scripts/to-monitor-list.ts

"use strict";class MonitoringListManager{api=new mw.Api;link;toCheck;totalToCheck;isRunning=!1;handledRequests=0;load{const i=document.querySelector(".mw-editsection").cloneNode(!0);this.link=document.createElement("a"),this.link.href="#",this.link.style.fontWeight="bold",this.link.textContent="Add missing counts",this.link.addEventListener("click",async a=>{if(a.preventDefault,!this.isRunning){this.isRunning=!0,await this.loadToCheckData;for(const e of this.toCheck.categories)this.handleCheck(e,async=>{const t=await this.api.get({action:"query",list:"search",srinfo:"totalhits",srnamespace:this.getCategory(e),srsearch:`incategory:"${e.category}"`}).catch((r,s)=>(mw.notify(`An error occurred while trying to get category members: ${s?.error.info??"Unknown error"} (${r})`,{type:"error"}),null));if(t)return t.query.searchinfo.totalhits});for(const e of this.toCheck.searches)this.handleCheck(e,async=>{const t=await this.api.get({action:"query",list:"search",srinfo:"totalhits",srnamespace:this.getCategory(e),srsearch:e.search}).catch((r,s)=>(mw.notify(`An error occurred while trying to get search results: ${s?.error.info??"Unknown error"} (${r})`,{type:"error"}),null));if(t)return t.query.searchinfo.totalhits});for(const e of this.toCheck.whatLinksHere)this.handleCheck(e,async=>{const t=await this.api.get({action:"query",list:"backlinks",bllimit:500,blnamespace:this.getCategory(e),bltitle:e.title}).catch((r,s)=>(mw.notify(`An error occurred while trying to get backlinks: ${s?.error.info??"Unknown error"} (${r})`,{type:"error"}),null));if(t)return t.query.backlinks.length});for(const e of this.toCheck.transclusions)this.handleCheck(e,async=>{const t=await this.api.get({action:"query",list:"embeddedin",eilimit:500,einamespace:this.getCategory(e),eititle:e.title}).catch((r,s)=>(mw.notify(`An error occurred while trying to get transclusions: ${s?.error.info??"Unknown error"} (${r})`,{type:"error"}),null));if(t)return t.query.embeddedin.length})}}),i.querySelector("a").replaceWith(this.link),document.querySelector("#Stuff_to_monitor.mw-headline").after(i)}async loadToCheckData{this.toCheck=JSON.parse((await this.api.get({action:"query",formatversion:"2",prop:"revisions",rvprop:"content",rvslots:"main",titles:"User:Eejit43/scripts/to-monitor-list.json"})).query.pages[0].revisions[0].slots.main.content),this.totalToCheck=Object.values(this.toCheck).flat.length}async handleCheck(i,a){const e=await a;if(e===void 0)return;const t=document.querySelector(`#to-monitor-list-${i.id}`);if(!t)return mw.notify(`Failed to find element for ID "${i.id}"`);t.innerHTML=e===0?' None ':` ${e===500?"500+":e} `,this.handledRequests++,this.link.textContent=`Add missing counts (${this.handledRequests}/${this.totalToCheck} loaded)`,this.handledRequests===this.totalToCheck&&setTimeout(=>{this.isRunning=!1,this.handledRequests=0,this.link.textContent="Add missing counts"},1e3)}getCategory({namespace:i,notNamespace:a}){if(!i&&!a)return 0;if(i){const e=Object.entries(mw.config.get("wgFormattedNamespaces")).find(([,t])=>t===i);return e?Number.parseInt(e[0]):0}else return Object.entries(mw.config.get("wgFormattedNamespaces")).filter(([,e])=>a!==(e||"Article")).map(([e])=>Number.parseInt(e))}}mw.loader.using(["mediawiki.util"],=>{mw.config.get("wgPageName")==="User:Eejit43"&&new MonitoringListManager.load});

// //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc2NyaXB0cy90by1tb25pdG9yLWxpc3QudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImltcG9ydCB7IEFwaVF1ZXJ5QmFja2xpbmtzUGFyYW1zLCBBcGlRdWVyeVJldmlzaW9uc1BhcmFtcywgQXBpUXVlcnlTZWFyY2hQYXJhbXMgfSBmcm9tICd0eXBlcy1tZWRpYXdpa2kvYXBpX3BhcmFtcyc7XG5pbXBvcnQgeyBCYWNrbGlua3NSZXN1bHQsIEVtYmVkZGVkaW5SZXN1bHQsIE1lZGlhV2lraURhdGFFcnJvciwgUGFnZVJldmlzaW9uc1Jlc3VsdCwgU2VhcmNoUmVzdWx0IH0gZnJvbSAnLi4vZ2xvYmFs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W5jICgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YTogU2VhcmNoUmVzdWx0IHwgbnVsbCA9IGF3YWl0IHRoaXMuYXBpXG4gICAgICAgICAgICAgICAgICAgICAgICAuZ2V0KHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb246ICdxdWVyeScsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlzdDogJ3NlYXJjaCcsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JpbmZvOiAndG90YWxoaXRzJyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcm5hbWVzcGFjZTogdGhpcy5nZXRDYXRlZ29yeShjaGVjayksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JzZWFyY2g6IGBpbmNhdGVnb3J5OlwiJHtjaGVjay5jYXRlZ29yeX1cImAsXG4gICAgICAgICAgICAgICAgICAgICAgICB9IHNhdGlzZmllcyBBcGlRdWVyeVNlYXJjaFBhcmFtcylcbiAgICAgICAgICAgICAgICAgICAgICAgIC5jYXRjaCgoZXJyb3JDb2RlOiBzdHJpbmcsIGVycm9ySW5mbzogTWVkaWFXaWtpRGF0YUVycm9yKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbXcubm90aWZ5KGBBbiBlcnJvciBvY2N1cnJlZCB3aGlsZSB0cnlpbmcgdG8gZ2V0IGNhdGVnb3J5IG1lbWJlcnM6ICR7ZXJyb3JJbmZvPy5lcnJvci5pbmZvID8/ICdVbmtub3duIGVycm9yJ30gKCR7ZXJyb3JDb2RlfSlgLCB7IHR5cGU6ICdlcnJvcicgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFkYXRhKSByZXR1cm47XG5cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChkYXRhIGFzIFNlYXJjaFJlc3VsdCkucXVlcnkuc2VhcmNoaW5mby50b3RhbGhpdHM7XG4gICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIGZvciAoY29uc3QgY2hlY2sgb2YgdGhpcy50b0NoZWNrLnNlYXJjaGVzKVxuICAgICAgICAgICAgICAgIHRoaXMuaGFuZGxlQ2hlY2soY2hlY2ssIGFzeW5jICgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YTogU2VhcmNoUmVzdWx0IHwgbnVsbCA9IGF3YWl0IHRoaXMuYXBpXG4gICAgICAgICAgICAgICAgICAgICAgICAuZ2V0KHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb246ICdxdWVyeScsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlzdDogJ3NlYXJjaCcsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JpbmZvOiAndG90YWxoaXRzJyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcm5hbWVzcGFjZTogdGhpcy5nZXRDYXRlZ29yeShjaGVjayksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JzZWFyY2g6IGNoZWNrLnNlYXJjaCxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gc2F0aXNmaWVzIEFwaVF1ZXJ5U2VhcmNoUGFyYW1zKVxuICAgICAgICAgICAgICAgICAgICAgICAgLmNhdGNoKChlcnJvckNvZGU6IHN0cmluZywgZXJyb3JJbmZvOiBNZWRpYVdpa2lEYXRhRXJyb3IpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdy5ub3RpZnkoYEFuIGVycm9yIG9jY3VycmVkIHdoaWxlIHRyeWluZyB0byBnZXQgc2VhcmNoIHJlc3VsdHM6ICR7ZXJyb3JJbmZvPy5lcnJvci5pbmZvID8/ICdVbmtub3duIGVycm9yJ30gKCR7ZXJyb3JDb2RlfSlgLCB7IHR5cGU6ICdlcnJvcicgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFkYXRhKSByZXR1cm47XG5cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChkYXRhIGFzIFNlYXJjaFJlc3VsdCkucXVlcnkuc2VhcmNoaW5mby50b3RhbGhpdHM7XG4gICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIGZvciAoY29uc3QgY2hlY2sgb2YgdGhpcy50b0NoZWNrLndoYXRMaW5rc0hlcmUpXG4gICAgICAgICAgICAgICAgdGhpcy5oYW5kbGVDaGVjayhjaGVjaywgYXN5bmMgKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhOiBCYWNrbGlua3NSZXN1bHQgfCBudWxsID0gYXdhaXQgdGhpcy5hcGlcbiAgICAgICAgICAgICAgICAgICAgICAgIC5nZXQoe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbjogJ3F1ZXJ5JyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaXN0OiAnYmFja2xpbmtzJyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBibGxpbWl0OiA1MDAsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYmxuYW1lc3BhY2U6IHRoaXMuZ2V0Q2F0ZWdvcnkoY2hlY2spLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJsdGl0bGU6IGNoZWNrLnRpdGxlLFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBzYXRpc2ZpZXMgQXBpUXVlcnlCYWNrbGlua3NQYXJhbXMpXG4gICAgICAgICAgICAgICAgICAgICAgICAuY2F0Y2goKGVycm9yQ29kZTogc3RyaW5nLCBlcnJvckluZm86IE1lZGlhV2lraURhdGFFcnJvcikgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG13Lm5vdGlmeShgQW4gZXJyb3Igb2NjdXJyZWQgd2hpbGUgdHJ5aW5nIHRvIGdldCBiYWNrbGlua3M6ICR7ZXJyb3JJbmZvPy5lcnJvci5pbmZvID8/ICdVbmtub3duIGVycm9yJ30gKCR7ZXJyb3JDb2RlfSlgLCB7IHR5cGU6ICdlcnJvcicgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFkYXRhKSByZXR1cm47XG5cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChkYXRhIGFzIEJhY2tsaW5rc1Jlc3VsdCkucXVlcnkuYmFja2xpbmtzLmxlbmd0aDtcbiAgICAgICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgZm9yIChjb25zdCBjaGVjayBvZiB0aGlzLnRvQ2hlY2sudHJhbnNjbHVzaW9ucylcbiAgICAgICAgICAgICAgICB0aGlzLmhhbmRsZUNoZWNrKGNoZWNrLCBhc3luYyAoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGE6IEVtYmVkZGVkaW5SZXN1bHQgfCBudWxsID0gYXdhaXQgdGhpcy5hcGlcbiAgICAgICAgICAgICAgICAgICAgICAgIC5nZXQoe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbjogJ3F1ZXJ5JyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaXN0OiAnZW1iZWRkZWRpbicsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZWlsaW1pdDogNTAwLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVpbmFtZXNwYWNlOiB0aGlzLmdldENhdGVnb3J5KGNoZWNrKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlaXRpdGxlOiBjaGVjay50aXRsZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gc2F0aXNmaWVzIEFwaVF1ZXJ5QmFja2xpbmtzUGFyYW1zKVxuICAgICAgICAgICAgICAgICAgICAgICAgLmNhdGNoKChlcnJvckNvZGU6IHN0cmluZywgZXJyb3JJbmZvOiBNZWRpYVdpa2lEYXRhRXJyb3IpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdy5ub3RpZnkoYEFuIGVycm9yIG9jY3VycmVkIHdoaWxlIHRyeWluZyB0byBnZXQgdHJhbnNjbHVzaW9uczogJHtlcnJvckluZm8/LmVycm9yLmluZm8gPz8gJ1Vua25vd24gZXJyb3InfSAoJHtlcnJvckNvZGV9KWAsIHsgdHlwZTogJ2Vycm9yJyB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICBpZiAoIWRhdGEpIHJldHVybjtcblxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gKGRhdGEgYXMgRW1iZWRkZWRpblJlc3VsdCkucXVlcnkuZW1iZWRkZWRpbi5sZW5ndGg7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIGZ1bGxMaW5rRWxlbWVudC5xdWVyeVNlbGVjdG9yKCdhJykhLnJlcGxhY2VXaXRoKHRoaXMubGluayk7XG5cbiAgICAgICAgZG9jdW1lbnQucXVlcnlTZWxlY3RvcignI1N0dWZmX3RvX21vbml0b3IubXctaGVhZGxpbmUnKSEuYWZ0ZXIoZnVsbExpbmtFbGVtZW50KTtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBMb2FkcyB0aGUgZGF0YSBvZiBjaGVja3MgdG8gaGFuZGxlLlxuICAgICAqL1xuICAgIHB1YmxpYyBhc3luYyBsb2FkVG9DaGVja0RhdGEoKSB7XG4gICAgICAgIHRoaXMudG9DaGVjayA9IEpTT04ucGFyc2UoXG4gICAgICAgICAgICAoXG4gICAgICAgICAgICAgICAgKGF3YWl0IHRoa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