🇮🇷 Iran Proxy | https://www.wikipedia.org/wiki/User:Oshwah/AFLog-UserLinks.js
Jump to content

User:Oshwah/AFLog-UserLinks.js

From Wikipedia, the free encyclopedia
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.
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");

	if (special_pagename === "AbuseLog") {
		// good to go, now we loop through <li>s that have '.mw-userlink' AND '.mw-usertoollinks' inside them
		$("li:has(.mw-userlink):has(.mw-usertoollinks)").each(function () {
			// pick the first '.mw-userlink';
			
			const user_tool_links = $(this).find("span.mw-usertoollinks").html();
			const relevant_user = $(this).find(".mw-userlink").first().text();
			const encoded_username = encodeURIComponent(relevant_user);

			// generate all the links we want to append
			const usertalk_link = user_tool_links.match("^(.*)>talk</a>");
			const contribs_link = 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/${relevant_user}">contribs</a>`):(contribs_link[0]));

			const block_link = `<a href="https://en.wikipedia.org/wiki/Special:Block/${relevant_user}">block</a>`;
			// encoding IPs is a-okay
			const publiclog_link = `<a href="https://en.wikipedia.org/wiki/Special:Log?user=${encoded_username}">logs</a>`;
			const checkuser_link = `<a href="https://en.wikipedia.org/w/index.php?title=Special:CheckUser&user=${encoded_username}">checkuser</a>`;
			const checklog_link = `<a href="https://en.wikipedia.org/w/index.php?title=Special:CheckUserLog&cuSearchType=target&cuSearch=${encoded_username}">checks</a>`;

			const new_links = [usertalk_link[0]];

			new_links.push(
				contribs_link2,
				publiclog_link
			);

			if (mw.util.isIPAddress(relevant_user)) {
				const whois_link = `<a href="https://tools.wmflabs.org/whois-referral/gateway.py?lookup=true&ip=${encoded_username}">WHOIS</a>`;
				const geolocate_link = `<a href="https://whatismyipaddress.com/ip/${relevant_user}">geolocate</a>`;
				const proxy_check_link = `<a href="https://spur.us/context/${relevant_user}">proxy</a>`;
				const bullseye_check_link = `<a href="https://bullseye.toolforge.org/ip/${relevant_user}">bullseye</a>`;

				new_links.push(
					whois_link,
					geolocate_link,
					proxy_check_link,
					bullseye_check_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(" | ") + ")";

			$(this).find("span.mw-usertoollinks").html(new_links_str);
	});
}});//TESTED WORKING AS OF THIS REVISION.