From Wikipedia, the free encyclopedia
Content deleted Content added
|
 |
|||
| Line 20: | Line 20: | ||
|
const performer_usertalk_link = performer_usertalk_temp[0]; //Grab existing HTML of the talk page link from the existing ‘.mw-usertoollinks’ HTML. |
const performer_usertalk_link = performer_usertalk_temp[0]; //Grab existing HTML of the talk page link from the existing ‘.mw-usertoollinks’ HTML. |
||
|
const performer_contribs_temp = performer_user_tool_links.match(‘<a href=”https://en.wikipedia.org/wiki/Special:Contributions(.*)>contribs</a>”); |
const performer_contribs_temp = performer_user_tool_links.match(‘<a href=”https://en.wikipedia.org/wiki/Special:Contributions(.*)>contribs</a>”); |
||
|
const performer_contribs_link = ((performer_contribs_temp == null)?(‘<a href=”https://en.wikipedia.org/wiki/Special:Contributions/’ + performer_username + ‘”>contribs</a>’):(performer_contribs_temp[0])); //If the current performer links don’t contain a contribs link (IP address), we must create our own instead. |
|||
|
const performer_contribs_link = performer_contribs_temp[0]; |
|||
|
const performer_block_link = ‘<a href=”https://en.wikipedia.org/wiki/Special:Block/’ + performer_username + ‘”>block</a>’; |
const performer_block_link = ‘<a href=”https://en.wikipedia.org/wiki/Special:Block/’ + performer_username + ‘”>block</a>’; |
||
| Line 47: | Line 47: | ||
|
const target_usertalk_link = target_usertalk_temp[0]; //Grab existing HTML of the talk page link from the existing ‘.mw-usertoollinks’ HTML. |
const target_usertalk_link = target_usertalk_temp[0]; //Grab existing HTML of the talk page link from the existing ‘.mw-usertoollinks’ HTML. |
||
|
const target_contribs_temp = target_user_tool_links.match(‘<a href=”https://en.wikipedia.org/wiki/Special:Contributions(.*)>contribs</a>”); |
const target_contribs_temp = target_user_tool_links.match(‘<a href=”https://en.wikipedia.org/wiki/Special:Contributions(.*)>contribs</a>”); |
||
|
const target_contribs_link = ((target_contribs_temp == null)?(‘<a href=”https://en.wikipedia.org/wiki/Special:Contributions/’ + target_username + ‘”>contribs</a>’):(target_contribs_temp[0])); //If the current target links don’t contain a contribs link ( |
const target_contribs_link = ((target_contribs_temp == null)?(‘<a href=”https://en.wikipedia.org/wiki/Special:Contributions/’ + target_username + ‘”>contribs</a>’):(target_contribs_temp[0])); //If the current target links don’t contain a contribs link (IP ), we must create our own instead. |
||
|
const target_block_link = ‘<a href=”https://en.wikipedia.org/wiki/Special:Block/’ + target_username + ‘”>block</a>’; |
const target_block_link = ‘<a href=”https://en.wikipedia.org/wiki/Special:Block/’ + target_username + ‘”>block</a>’; |
||
Latest revision as of 05:59, 3 December 2025
//<nowiki>
mw.loader.using("mediawiki.util", function () {
const special_pagename = mw.config.get("wgCanonicalSpecialPageName"); //Get name of the current special page, e.g. 'AbuseLog'; if we're not on a special page, this returns null.
if (special_pagename === "Log") { //Only proceed if this is a special page and if the current special page is Special:Log.
const ip_pattern = /^(?:(?:(?:1?\d?\d|2[0-4]\d|25[0-5])\.){3}(?:1?\d?\d|2[0-4]\d|25[0-5])|(?:[\da-f]{0,4}:){1,7}[\da-f]{0,4})(?:\/\d{1,2})?$/i;
const cidr_pattern = /\/\d{1,2}$/; //We must define the patterns for an IP and for a CIDR and check ourselves, as the built-in mw.util.isIPAddress() function returns false for IP CIDR ranges.
$("li:has(a.mw-userlink):has(.mw-usertoollinks)").each(function () { //Loop through <li>s that have '.mw-userlink' AND '.mw-usertoollinks' inside them.
const performer_user_tool_links = $(this).children(".mw-usertoollinks").first().html(); //Pull data for performing user.
const performer_username = $(this).children(".mw-userlink").first().text();
const encoded_performer_username = encodeURIComponent(performer_username);
const target_user_tool_links = $(this).children(".mw-usertoollinks").last().html(); //Pull data for target user (if one exists).
const target_username = $(this).children(".mw-userlink").last().text();
const encoded_target_username = encodeURIComponent(target_username);
const performer_usertalk_temp = performer_user_tool_links.match('^(.*)>talk</a>');
const performer_usertalk_link = performer_usertalk_temp[0]; //Grab existing HTML of the talk page link from the existing '.mw-usertoollinks' HTML.
const performer_contribs_temp = performer_user_tool_links.match('<a href="/wiki/Special:Contributions(.*)>contribs</a>');
const performer_contribs_link = ((performer_contribs_temp == null)?('<a href="https://en.wikipedia.org/wiki/Special:Contributions/' + performer_username + '">contribs</a>'):(performer_contribs_temp[0])); //If the current performer links don't contain a contribs link (IP address), we must create our own instead.
const performer_block_link = '<a href="https://en.wikipedia.org/wiki/Special:Block/' + performer_username + '">block</a>';
const performer_publiclog_link = '<a href="https://en.wikipedia.org/wiki/Special:Log?user=' + encoded_performer_username + '">logs</a>';
const performer_checkuser_link = '<a href="https://en.wikipedia.org/w/index.php?title=Special:CheckUser&user=' + encoded_performer_username + '">checkuser</a>';
const performer_checklog_link = '<a href="https://en.wikipedia.org/w/index.php?title=Special:CheckUserLog&cuSearchType=target&cuSearch=' + encoded_performer_username + '">checks</a>';
let performer_new_links = [performer_usertalk_link]; //Create array of strings to hold HTML elements for each button for the performer, set first element to the user talk page link.
performer_new_links.push(performer_contribs_link, performer_publiclog_link); //Add HTML link to performer contributions and performer logs as next two elements.
if (ip_pattern.test(performer_username)) { //The performer username is an IP address (the performer will never be a CIDR range), meaning that we have more links to create and add.
const performer_whois_link = '<a href="https://tools.wmflabs.org/whois-referral/gateway.py?lookup=true&ip=' + encoded_target_username + '">WHOIS</a>'; //Create additional links for the IP user.
const performer_geolocate_link = '<a href="https://whatismyipaddress.com/ip/' + target_username + '">geolocate</a>';
const performer_proxy_check_link = '<a href="https://spur.us/context/' + target_username + '">proxy</a>';
const performer_bullseye_check_link = '<a href="https://bullseye.toolforge.org/ip/' + target_username + '">bullseye</a>';
performer_new_links.push(performer_whois_link, performer_geolocate_link, performer_proxy_check_link, performer_bullseye_check_link); //Add performer IP tool links to the array.
}
performer_new_links.push(performer_checkuser_link, performer_checklog_link, performer_block_link); //Add the ending performer links to the array.
const performer_new_links_str = performer_new_links.join(' | ') + '</span>'; //Join each element of the performer links together, separated by ' | ', add a closing </span> tag, and place into to a singular string.
$(this).children(".mw-usertoollinks").first().html(performer_new_links_str);//Write the new HTML string back to the performer '.mw-usertoollinks' span object and replace the old HTML.
if (performer_username != target_username) { //The log entry has no target user, so there's only one '.mw-usertoollinks' span object to replace.
const target_usertalk_temp = target_user_tool_links.match('^(.*)>talk</a>');
const target_usertalk_link = target_usertalk_temp[0]; //Grab existing HTML of the talk page link from the existing '.mw-usertoollinks' HTML.
const target_contribs_temp = target_user_tool_links.match('<a href="/wiki/Special:Contributions(.*)>contribs</a>');
const target_contribs_link = ((target_contribs_temp == null)?('<a href="https://en.wikipedia.org/wiki/Special:Contributions/' + target_username + '">contribs</a>'):(target_contribs_temp[0])); //If the current target links don't contain a contribs link (IP address), we must create our own instead.
const target_block_link = '<a href="https://en.wikipedia.org/wiki/Special:Block/' + target_username + '">block</a>';
const target_publiclog_link = '<a href="https://en.wikipedia.org/wiki/Special:Log?user=' + encoded_target_username + '">logs</a>';
const target_checkuser_link = '<a href="https://en.wikipedia.org/w/index.php?title=Special:CheckUser&user=' + encoded_target_username + '">checkuser</a>';
const target_checklog_link = '<a href="https://en.wikipedia.org/w/index.php?title=Special:CheckUserLog&cuSearchType=target&cuSearch=' + encoded_target_username + '">checks</a>';
let target_new_links = [target_usertalk_link]; //Create array of strings to hold HTML elements for each button for the target, set first element to the user talk page link.
if (ip_pattern.test(target_username)) { //The target username is an IP address (the target will never be a CIDR range), meaning that we have more links to create and add.
const target_whois_link = '<a href="https://tools.wmflabs.org/whois-referral/gateway.py?lookup=true&ip=' + encoded_target_username + '">WHOIS</a>'; //Create additional links for the IP user.
const target_geolocate_link = '<a href="https://whatismyipaddress.com/ip/' + target_username + '">geolocate</a>';
const target_proxy_check_link = '<a href="https://spur.us/context/' + target_username + '">proxy</a>';
const target_bullseye_check_link = '<a href="https://bullseye.toolforge.org/ip/' + target_username + '">bullseye</a>';
if (cidr_pattern.test(target_username)) { //If the target is an IP address CIDR range, reset the array of new links to be the contribs link instead of the user talk page link (user talk pages will never exist for a CIDR range).
target_new_links = [target_contribs_link];
} else {
target_new_links.push(target_contribs_link); //Add target IP contribs link to the array.
}
target_new_links.push(target_publiclog_link, target_whois_link, target_geolocate_link, target_proxy_check_link, target_bullseye_check_link); //Add target IP tool links to the array.
} else {
target_new_links.push(target_contribs_link, target_publiclog_link); //Add the beginning target links to the array.
}
target_new_links.push(target_checkuser_link, target_checklog_link, target_block_link); //Add the ending target links to the array.
const target_new_links_str = target_new_links.join(' | ') + '</span>'; //Join each element of the target links together, separated by ' | ', add a closing </span> tag, and place into to a singular string.
$(this).children(".mw-usertoollinks").last().html(target_new_links_str);//Write the new HTML string back to the target '.mw-usertoollinks' span object and replace the old HTML.
}
});
}
});
//</nowiki>


