User:Awesome Aasim/usergroups.js

if (!UG) { var UG = {}; $(document).ready(function {	   if (mw.config.get("wgNamespaceNumber") == 2 || mw.config.get("wgNamespaceNumber") == 3) {	        var url = mw.config.get( 'wgScriptPath' ) + '/api.php'; 	        var user = "";	        if (mw.config.get("wgCanonicalSpecialPageName")) {	            user = mw.config.get("wgTitle").split("/")[1];	        } else {	            user = mw.config.get("wgTitle").split("/")[0];	        }	        var params = {	            action: "query",	            list: "users",	            ususers: user,	            usprop: "blockinfo|groups",	            format: "json"	        };	        $.get(url, params).done(function(response) { var userdata = response.query.users[0]; $("#siteSub").text("") $("#siteSub").append($(' ')); if (userdata.blockid) { $("#usergroups").append(' This user is currently blocked (see reason below): ' + userdata.blockedby + ' blocked this user with the reason: ' + userdata.blockreason + ' Block ID:' + userdata.blockid + ' Expiry:  ' + userdata.blockexpiry + ' '); $("#usergroups-blockreason").text(userdata.blockreason); }               var usergroups = ""; for (var i = 0; i < userdata.groups.length; i++) { if (userdata.groups[i] == "sysop") { $("#usergroups").append('administrator '); } else if (userdata.groups[i] == "bureaucrat") { $("#usergroups").append('bureaucrat '); } else if (userdata.groups[i] == "bot") { $("#usergroups").append('bot '); } else if (userdata.groups[i] == "interface-admin") { $("#usergroups").append('interface-administrator '); } else if (userdata.groups[i] != "*" && userdata.groups[i] != "user" && userdata.groups[i] != "autoconfirmed") { $("#usergroups").append(userdata.groups[i] + ' '); }               }	        });	    }	}); }