Content deleted Content added
Polygnotus (talk | contribs) No edit summary |
Polygnotus (talk | contribs) improve ignoring subpages of userpages |
||
Line 48:
const processedUsers = new Set();
const userGroups = loadCache();
// Check if a URL path is a subpage
function isSubpage(path) {
// First decode the URL to handle any encoded characters
const decodedPath = decodeURIComponent(path);
// Remove any URL parameters or fragments
const cleanPath = decodedPath.split(/[?#]/)[0];
// Check if there's a slash after "User:"
return /User:[^/]+\//.test(cleanPath);
}
// Find all user links in signatures
Line 69 ⟶ 79:
}
//
if (
return false;
}
} else {
// For redlinks, check the title parameter
const url = new URL(href, window.___location.origin);
const title = url.searchParams.get('title');
if (title && isSubpage(title)) {
return false;
}
}
return true;
});
Line 94 ⟶ 111:
// Handle both regular wiki links and redlinks
if (href.startsWith('/wiki/')) {
match = decodeURIComponent(href).match(/User:([^/?&#
} else {
// For redlinks, check the title parameter
Line 100 ⟶ 117:
const title = url.searchParams.get('title');
if (title) {
match = decodeURIComponent(title).match(/User:([^/?&#
}
}
// Remove any subpage part if it somehow got through
const username = match[1].split('/')[0];
return username.replace(/_/g, ' ');
}
return null;
}
|