User:LordTBT/common.js

(function($, mw) {   if (mw.config.get('wgServer') !== 'http://redwall.wikia.com') {        return;    }    var regex = /\d+/;    var blogs = Array.prototype.map.call( document.getElementsByClassName('bloglist'), function(ev) { return ev.innerText; }   );    function getData(callback) {        new mw.Api.get({ action: 'query', list: 'categorymembers', cmtitle: 'Category:News_posts', cmsort: 'timestamp', cmdir: 'desc', cmlimit: 5, format: 'json' }).done(function(d) { if(!d.error) { callback(d); }       });    }    function processData(result) {        var data = result.query.categorymembers;        blogs.forEach(function(value) { regex.exec(value).forEach(function(result) {               var blog = data[Number(result) - 1].title;                var edited = blog.split('/')[1]; //Kinda janked, may not always work                var link = mw.config.get('wgArticlePath').replace('$1', mw.util.wikiUrlencode(blog));                var requiredElement = document.getElementsByClassName('bloglist')[Number(result) - 1];                $(requiredElement).html('' + edited + '');            }); });   }    getData(processData); })(this.jQuery, this.mediaWiki);