From Wikipedia, the free encyclopedia
Content deleted Content added
|
|
|||
| Line 16: | Line 16: | ||
|
const cu_username = $(this).find(“.mw-userlink”).first().text(); |
const cu_username = $(this).find(“.mw-userlink”).first().text(); |
||
|
const encoded_cu_username = encodeURIComponent(cu_username); |
const encoded_cu_username = encodeURIComponent(cu_username); |
||
|
const target_user_tool_links = $(this).find(“span.mw-usertoollinks”).next().next().html(); |
const target_user_tool_links = $(this).find(“span.mw-usertoollinks”).next().next().html(); |
||
|
const target_username = $(this).find(“.mw-userlink” |
const target_username = $(this).find(“.mw-userlink”).next().next().next().text(); |
||
|
const encoded_target_username = encodeURIComponent(target_username); |
const encoded_target_username = encodeURIComponent(target_username); |
||
Latest revision as of 20:17, 29 November 2025
mw.loader.using("mediawiki.util", function () {
const action = mw.config.get("wgAction"); // e.g., 'view', 'edit', 'history'
/* gets you the name of the current special page, e.g. 'AbuseLog';
if we're not on a special page, this returns null */
const special_pagename = mw.config.get("wgCanonicalSpecialPageName");
const cidr_pattern = /\/\d{1,2}$/;
var i = 0;
if (special_pagename === "CheckUserLog") {
// good to go, now we loop through <li>s that have '.mw-userlink' AND '.mw-usertoollinks' inside them
$("li:has(a.mw-userlink):has(.mw-usertoollinks)").each(function () {
// pick the first '.mw-userlink';
const cu_user_tool_links = $(this).find("span.mw-usertoollinks").html();
const cu_username = $(this).find(".mw-userlink").first().text();
const encoded_cu_username = encodeURIComponent(cu_username);
const target_user_tool_links = $(this).find("span.mw-usertoollinks").next().next().next().html();
const target_username = $(this).find(".mw-userlink").next().next().next().text();
const encoded_target_username = encodeURIComponent(target_username);
// generate all the links we want to append
const usertalk_link = cu_user_tool_links.match("^(.*)>talk</a>");
const usertalk_link2 = ((usertalk_link == null)?(`<a href="https://en.wikipedia.org/wiki/User_talk:${cu_username}">talk</a>`):(usertalk_link[0]));//Check if the link to the user talk page was captured from user_tools_link. If the string is null, insert the HTML code ourselves. Otherwise, flatten the array.
const contribs_link = cu_user_tool_links.match("<a href=\"/wiki/Special:Contributions(.*)>contribs</a>");
const contribs_link2 = ((contribs_link == null)?(`<a href="https://en.wikipedia.org/wiki/Special:Contributions/${cu_username}">contribs</a>`):(contribs_link[0]));
const block_link = `<a href="https://en.wikipedia.org/wiki/Special:Block/${cu_username}">block</a>`;
// encoding IPs is a-okay
const publiclog_link = `<a href="https://en.wikipedia.org/wiki/Special:Log?user=${encoded_cu_username}">logs</a>`;
const checkuser_link = `<a href="https://en.wikipedia.org/w/index.php?title=Special:CheckUser&user=${encoded_cu_username}">checkuser</a>`;
const checklog_link = `<a href="https://en.wikipedia.org/w/index.php?title=Special:CheckUserLog&cuSearchType=target&cuSearch=${encoded_cu_username}">checks</a>`;
var new_links;
if (mw.util.isIPAddress(cu_username)) {
const whois_link = `<a href="https://tools.wmflabs.org/whois-referral/gateway.py?lookup=true&ip=${encoded_cu_username}">WHOIS</a>`;
const geolocate_link = `<a href="https://whatismyipaddress.com/ip/${cu_username}">geolocate</a>`;
const proxy_check_link = `<a href="https://spur.us/context/${cu_username}">proxy</a>`;
const bullseye_check_link = `<a href="https://bullseye.toolforge.org/ip/${cu_username}">bullseye</a>`;
if (!(cidr_pattern.test(cu_username))) {
new_links = [usertalk_link2];
} else {
new_links = [contribs_link2];
}
new_links.push(
whois_link,
geolocate_link,
proxy_check_link,
bullseye_check_link
);
} else {
new_links = [usertalk_link2];
new_links.push(
contribs_link2,
publiclog_link
);
}
new_links.push(checkuser_link, checklog_link, block_link); // these are appended after IP-related links
// turn the array of links into "link1 | link2..."
const new_links_str = "(" + new_links.join(" | ") + ")";
if (i % 2 != 0) {
$(this).find("span.mw-usertoollinks").html(new_links_str);
}
i++;
});
}});

