User:Mooziq/global.js

//making Wikia FANDOM better. One script at a time. console.log("Running global.js version 1.1"); (function ($, mw) {   if (mw.config.get("wgCanonicalNamespace") == "Thread") {        //put thread manipulations here        var threadname = mw.config.get("wgPageName");        if (!threadname) threadname = "NotFound";        addThreadNames;    }    //do other stuff later    //add thread names     function addThreadNames {        //cancel if we can't find thread messages        var tmsgs = $(".speech-bubble-message > .MiniEditorWrapper");        if (!tmsgs || tmsgs.length < 1){            console.log("global.js - Could not find thread messages!");            return;        }        //do stuff for each message        tmsgs.each(function(i){ var msg = $(this); //get message name (href link) var tnlink = msg.find(".timestamp > a.permalink").attr("href"); var tmname = "NotFound"; if (tnlink){ tmname = tnlink.substr(tnlink.lastIndexOf('/')+1); }           //build thread name element var tnel = $.parseHTML(" " + tmname + " "); //get message author element or continue to next message var tmauth = msg.find(".edited-by"); if (tmauth.length < 1) return true; //add thread name tmauth.append(tnel); });   } }(jQuery, mediaWiki));