User:Theleekycauldron/Scripts/4bes.js

/* Copyright (c) 2023 theleekycauldron

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

function capitalize(string) { return string.charAt(0).toUpperCase + string.slice(1); } $.when(	mw.loader.using('ext.gadget.morebits'),	$.ready ).then(async function {	console.log("ready!");	if (mw.config.get('wgPageName').includes("Wikipedia:Four_Award")) {		$(mw.util.addPortletLink('p-cactions', '#', '4bes')).click(give);	} });

give = async function (e) { e.preventDefault; var Window = new Morebits.simpleWindow(400, 300); Window.setTitle("Four Award Bestower (4bes)"); var form = new Morebits.quickForm; let result; function show{ result = form.render; Window.setContent(result); Window.display; }	let today = new Date let months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "the one we keep secret"] today = `${months[today.getMonth]} ${today.getDate}, ${today.getFullYear}` form.append({type: 'input', name: 'user', label: 'User:'}) form.append({type: 'input', name: 'article', label: 'Article:'}) form.append({type: 'input', name: 'format', label: '       Article display text:'}) form.append({type: 'input', name: 'award-date', label: 'Award date:', value: today}) form.append({type: 'input', name: 'creation-date', label: 'Creation date:'}) form.append({type: 'input', name: 'dyk-date', label: 'DYK date:'}) form.append({type: 'input', name: 'ga-date', label: 'GA date:'}) form.append({type: 'input', name: 'fa-date', label: 'FA date:'}) form.append({type: 'button', name: 'submit', label: 'submit!', event: function l{evaluate(e, result)}}); show; evaluate = async function (e, result){ await get_pages("Wikipedia:Four Award/Records","user|content",null,"older").then((res) => {			let page   = res			let content = page[0].revisions[0].slots.main.content;			content = content.split("\n");			let m=1;			let save=-1;			let line;			for (let i=0; iresult.user.value)				if (user==result.user.value){					m++;					}				if (user>result.user.value){					save=i-1;					break;				}			}			console.log(save,m);		}) } } //