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 pagesconstnamespace=mw.config.get('wgNamespaceNumber');console.log('Current namespace:',namespace);if(namespace%2!==1){console.log('Not a talk page, exiting');return;}console.log('Running on talk page');constprocessedUsers=newSet();constuserGroups=newMap();// Find all user links in signaturesfunctionfindUserLinks(){// Find links to user pages that aren't inside the "talk" part of signatures// and only within the main content areaconstlinks=$('#content a[href^="/wiki/User:"]:not([href*="talk"]):not([data-ec-checked])');console.log('Found user links:',links.length);links.each((_,link)=>console.log('User link:',$(link).text(),$(link).attr('href')));returnlinks;}// Extract username from linkfunctiongetUsernameFromLink(link){consthref=$(link).attr('href');returnhref.replace('/wiki/User:','');}// Batch process users to reduce API callsasyncfunctionprocessUserBatch(users){if(users.length===0)return;constuserList=users.join('|');console.log('Fetching groups for users:',userList);try{constresponse=await$.ajax({url:mw.util.wikiScript('api'),data:{action:'query',format:'json',list:'users',usprop:'groups',ususers:userList,formatversion:'2'},dataType:'json'});console.log('API response:',response);if(response.query&&response.query.users){response.query.users.forEach(user=>{constgroups=user.groups||[];constisEC=groups.includes('extendedconfirmed');console.log(`User ${user.name}: EC=${isEC}, groups=${groups.join(',')}`);userGroups.set(user.name,isEC);});}}catch(error){console.error('Error fetching user groups:',error);}}// Add status indicator next to usernamefunctionaddStatusIndicator(link,isExtendedConfirmed){// Remove any existing indicators next to this link$(link).siblings('.ec-status-indicator').remove();constindicator=$('<span>').addClass('ec-status-indicator').css({'margin-left':'4px','font-size':'0.85em','color':isExtendedConfirmed?'#00a000':'#cc0000',// Green and red colors'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(){console.log('Processing page...');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>