User:QwerpQwertus/js.js

//Based on Gender dimorphism script by User:Fran Rogers // this a user page or user talk page if ((wgNamespaceNumber == 2 || wgNamespaceNumber == 3) &&   !/\//.test(wgTitle)) { // then when we visit said page... addOnloadHook(function {   var a = sajax_init_object;    //Ask the api the user's gender in json     a.open("GET", wgServer + wgScriptPath + "/api.php?format=json&action=query&list=users&ususers=" + escape(wgTitle.replace(/ /, "_")) + "&usprop=gender", true);   // wait till the api awnsers    queryapi.onreadystatechange = function {      if(queryapi.readyState == 4 && queryapi.status == 200) {        // parse - extract the gender word from the response (in json)        var genderText =           eval("(" + a.responseText + ")").query.users[0].gender;        // U+2640 is female and U+2642 male and U+00BF is an upside down question mark as found at http://en.wikipedia.org/wiki/Miscellaneous_Symbols - set them        var genderSymbol = "";        if (genderText == "female") {          genderSymbol = "&#x2640;";//Female - use that symbol        } else if (genderText == "male") {          genderSymbol = "&#x2642;";//male - use that symbol        } else if (genderText == "undefined") {          genderSymbol = "&#x00BF;";//not set - use that symbol        }        // add the symbol        if (genderSymbol != "") {          document.getElementById("firstHeading").innerHTML += " " + genderSymbol; }     }    };    // ask the api - the rest of the script is waiting queryapi.send; }); }