User:TheGhostOfInky/common.js

function createItem(id, href, shortRef, title) { var titleTag = title ? '" title="' + title : ''; var elm = '' + shortRef + ''; return elm; }

function addTools { var pagesToAdd = [ {           "id": "userpage", "href": "User:", "shortRef": "User page" },       {            "id": "contributions", "href": "Special:Contributions/", "title": "A list of contributions by this user", "shortRef": "User contributions" },       {            "id": "log", "href": "Special:Log/", "shortRef": "Logs" },       {            "id": "blockip", "href": "Special:Block/", "shortRef": "Block user" },       {            "id": "userrights", "href": "Special:UserRights/", "shortRef": "Change user groups" }   ];    var currentPage = new window.mw.Title(mw.config.values.wgPageName);

if (currentPage.namespace === 200) { var toolsList = $(".cosmos-tools-list > ul:nth-child(1)");

var userName = currentPage.title.split("/")[0];

var elms = "";

for (var i = 0; i < pagesToAdd.length; i++) { var page = pagesToAdd[i]; var href = page.href + userName; elms += createItem(page.id, href, page.shortRef, page.title); }       $(toolsList).children("li:nth-child(2)").after(elms); } }

function viewHistory { $(".cosmos-recentChanges-page").each(function {        var link = $(this).children("a:nth-child(1)").attr("href");        var page = link.split("/wiki/")[1];        var href = "/w/index.php?title=" + page + "&action=history";        $(this).append( 'Revisions' );   }); }

window.addEventListener("load", function {    addTools;    viewHistory; }); /* $("textarea").on("keydown", function (e) {   if (e.which === 9) {        e.preventDefault;        var start = this.selectionStart,            end = this.selectionEnd, spaces = "    ";

this.value = this.value.substring(0, start) + spaces + this.value.substring(end);

this.selectionStart = this.selectionEnd = start + 4; } });