User:Anne drew Andrew and Drew/admintagger-plus.js

// Forked from User:Amorymeltzer/crathighlighter //

function createEmojiElement(char, title) { const emoji = document.createElement("span"); emoji.textContent = char; emoji.setAttribute("title", title); emoji.style.marginLeft = "1px"; return emoji; }

(function ($, mw) { let arbcomData = {};  let bureaucratData = {};  let oversightData = {};  let checkuserData = {};  let adminData = {};  let formerAdminData = {};  let stewardData = {};  let extendedConfirmedData = {};  let tenKData = {};  $.when( $.getJSON(     mw.config.get("wgScriptPath") +      "/index.php?action=raw&ctype=application/json&title=User:AmoryBot/crathighlighter.js/arbcom.json",      function (data) {        arbcomData = data;      }    ), $.getJSON(     mw.config.get("wgScriptPath") +      "/index.php?action=raw&ctype=application/json&title=User:AmoryBot/crathighlighter.js/oversight.json",      function (data) {        oversightData = data;      }    ), $.getJSON(     mw.config.get("wgScriptPath") +      "/index.php?action=raw&ctype=application/json&title=User:AmoryBot/crathighlighter.js/checkuser.json",      function (data) {        checkuserData = data;      }    ), $.getJSON(     mw.config.get("wgScriptPath") +      "/index.php?action=raw&ctype=application/json&title=User:NovemBot/userlist.js",      function (data) {        bureaucratData = data.bureaucrat;        stewardData = data.steward;        adminData = data.sysop;        formerAdminData = data.formeradmin;        extendedConfirmedData = data.extendedconfirmed;        tenKData = data['10k'];      }    ) ).then(function { ADMINHIGHLIGHT_EXTLINKS = window.ADMINHIGHLIGHT_EXTLINKS || false; ADMINHIGHLIGHT_NAMESPACES = [2, 3]; mw.loader.using(     ["mediawiki.util", "mediawiki.Uri", "mediawiki.Title"],      function  {        $("#mw-content-text a").each(function (_index, link) { try { const url = link.getAttribute("href"); if (!url || url.charAt(0) === "#") { return; // Skip  elements that aren't actually links; skip anchors }           if (              url.lastIndexOf("http://", 0) !== 0 &&              url.lastIndexOf("https://", 0) !== 0 &&              url.lastIndexOf("/", 0) !== 0            ) { return; //require http(s) links, avoid "javascript:..." etc. which mw.Uri does not support }           if (              link.parentElement.className &&              link.parentElement.classList[0] == "autocomment"            ) { return; // Skip span.autocomment links aka automatic section links in edit summaries }

if (link.id.indexOf("sectiontitlecopy") !== -1) { return; // avoid conflict with User:SoledadKabocha/copySectionLink.js           } if (link.className && link.classList[0] == "external") { return; // Avoid errors on hard-to-parse external links }

const uri = new mw.Uri(url); if (!ADMINHIGHLIGHT_EXTLINKS && !$.isEmptyObject(uri.query)) return; // Skip links with query strings if highlighting external links is disabled if (uri.host == "en.wikipedia.org") { const mwtitle = new mw.Title(               mw.util.getParamValue("title", url) ||                decodeURIComponent(uri.path.slice(6))              ); // Try to get the title parameter of URL; if not available, remove '/wiki/' and use that if (               $.inArray( mwtitle.getNamespaceId, ADMINHIGHLIGHT_NAMESPACES ) >= 0             ) {                let user = mwtitle.getMain.replace(/_/g, " ");

if (user.includes("/")) { // not a top-level user or user talk page return; }

let showEditCountEmoji = true;

const rolesContainer = document.createElement("sup"); if (adminData[user] == 1) { const admin = createEmojiElement("🧹", "Admin"); rolesContainer.appendChild(admin); showEditCountEmoji = false; } else if (formerAdminData[user] == 1) { const formerAdmin = createEmojiElement("*️⃣️", "Former Admin"); rolesContainer.appendChild(formerAdmin); showEditCountEmoji = false; }               if (arbcomData[user] == 1) { const arbcom = createEmojiElement("⚖️", "ArbCom"); rolesContainer.appendChild(arbcom); showEditCountEmoji = false; }               if (bureaucratData[user] == 1) { const bureaucrat = createEmojiElement("🔧", "Bureaucrat"); rolesContainer.appendChild(bureaucrat); showEditCountEmoji = false; }               if (checkuserData[user] == 1) { const checkuser = createEmojiElement("❓", "Checkuser"); rolesContainer.appendChild(checkuser); showEditCountEmoji = false; }               if (oversightData[user] == 1) { const oversighter = createEmojiElement("👁️", "Oversighter"); rolesContainer.appendChild(oversighter); showEditCountEmoji = false; }               if (stewardData[user] == 1) { const steward = createEmojiElement("🌐", "Steward"); rolesContainer.appendChild(steward); showEditCountEmoji = false; }

if (showEditCountEmoji) { if (tenKData[user] == 1) { const tenK = createEmojiElement("🟢", ">10k Edits"); rolesContainer.appendChild(tenK); } else if (extendedConfirmedData[user] == 1) { const extendedConfirmed = createEmojiElement("🟡", ">500 Edits"); rolesContainer.appendChild(extendedConfirmed); } else { const newUser = createEmojiElement("🔴", "New User"); rolesContainer.appendChild(newUser); }               }

rolesContainer.style.fontSize = "0.9em";

// append constructed span to user link link.parentNode.insertBefore(rolesContainer, link.nextSibling); }           }          } catch (e) { console.log(link); // Sometimes we will run into unparsable links, so just log these and move on           window.console && console.error("Admin tagger recoverable error", e.message); }       });      }    );  }); })(jQuery, mediaWiki); //