This is an old revision of this page, as edited by Polygnotus(talk | contribs) at 20:32, 12 February 2025(←Created page with '// <nowiki> // ExtendedConfirmedChecker.js // Adds indicators next to usernames on talk pages showing extended confirmed status // License: MIT $(function() { 'use strict'; // Only run on talk pages if (!mw.config.get('wgNamespaceNumber') % 2 === 1) { return; } const processedUsers = new Set(); const userGroups = new Map(); // Find all user links in signatures function findUserLinks() { return $('a...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.Revision as of 20:32, 12 February 2025 by Polygnotus(talk | contribs)(←Created page with '// <nowiki> // ExtendedConfirmedChecker.js // Adds indicators next to usernames on talk pages showing extended confirmed status // License: MIT $(function() { 'use strict'; // Only run on talk pages if (!mw.config.get('wgNamespaceNumber') % 2 === 1) { return; } const processedUsers = new Set(); const userGroups = new Map(); // Find all user links in signatures function findUserLinks() { return $('a...')
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// <nowiki>// ExtendedConfirmedChecker.js// Adds indicators next to usernames on talk pages showing extended confirmed status// License: MIT$(function(){'use strict';// Only run on talk pagesif(!mw.config.get('wgNamespaceNumber')%2===1){return;}constprocessedUsers=newSet();constuserGroups=newMap();// Find all user links in signaturesfunctionfindUserLinks(){return$('a.mw-userlink:not([data-ec-checked])');}// Extract username from linkfunctiongetUsernameFromLink(link){constusername=$(link).text();returnusername.replace(/^User:/,'');}// Batch process users to reduce API callsasyncfunctionprocessUserBatch(users){if(users.length===0)return;constuserList=users.join('|');try{constresponse=await$.ajax({url:mw.util.wikiScript('api'),data:{action:'query',format:'json',list:'users',usprop:'groups',ususers:userList}});if(response.query&&response.query.users){response.query.users.forEach(user=>{constgroups=user.groups||[];userGroups.set(user.name,groups.includes('extendedconfirmed'));});}}catch(error){console.error('Error fetching user groups:',error);}}// Add status indicator next to usernamefunctionaddStatusIndicator(link,isExtendedConfirmed){constindicator=$('<span>').addClass('ec-status-indicator').css({'margin-left':'4px','font-size':'0.85em','color':isExtendedConfirmed?'#14866d':'#72777d','cursor':'help'}).attr('title',isExtendedConfirmed?'Extended confirmed user':'Not extended confirmed').text(isExtendedConfirmed?'★':'☆');$(link).after(indicator);$(link).attr('data-ec-checked','true');}// Main processing functionasyncfunctionprocessPage(){constuserLinks=findUserLinks();constbatchSize=50;constusers=[];userLinks.each((_,link)=>{constusername=getUsernameFromLink(link);if(!processedUsers.has(username)){users.push(username);processedUsers.add(username);}});// Process users in batchesfor(leti=0;i<users.length;i+=batchSize){constbatch=users.slice(i,i+batchSize);awaitprocessUserBatch(batch);}// Add indicatorsuserLinks.each((_,link)=>{constusername=getUsernameFromLink(link);constisExtendedConfirmed=userGroups.get(username);addStatusIndicator(link,isExtendedConfirmed);});}// Run on page load and when new content is addedprocessPage();mw.hook('wikipage.content').add(processPage);});// </nowiki>