User:Polygnotus/Scripts/XC.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 70:
// Extract the path after User:
const userPath = href.match(/User:([^?&#/]+)/);
if (!userPath) {
return false;
}
// CheckOnly ifinclude theremain areuser anypages forward(no slashes after the usernamesubpages)
return !userPath[1].includes('/')true;
// This will exclude subpages like User:Example/subpage
return !userPath[1].includes('/');
});
console.log('Found user links:', links.length);
links.each((_, link) => console.log('User link:', $(link).text(), $(link).attr('href')));{
const username = getUsernameFromLink(link);
console.log('User link:', $(link).text(), '→', username, $(link).attr('href'));
});
return links;
}
Line 88 ⟶ 90:
function getUsernameFromLink(link) {
const href = $(link).attr('href');
constlet match = href.match(/User:([^/?&#]+)/);
return match ? match[1] : null;
// Handle both regular wiki links and redlinks
if (href.startsWith('/wiki/')) {
match = decodeURIComponent(href).match(/User:([^/?&#/]+)/);
} else {
// For redlinks, check the title parameter
const url = new URL(href, window.___location.origin);
const title = url.searchParams.get('title');
if (title) {
match = decodeURIComponent(title).match(/User:([^/?&#/]+)/);
}
}
return match ? match[1].replace(/_/g, ' ') : null;
}
 
Line 219 ⟶ 234:
userLinks.each((_, link) => {
const username = getUsernameFromLink(link);
if (username && !processedUsers.has(username)) {
users.push(username);
processedUsers.add(username);