User:DatRoot/Scripts/LogLink.js

/* Adds a link to the toolbox to display the logs for a page. To remove ambiguity, it renames the existing link titled "Logs" that appears on user pages to "User logs". Though both titles can be changed using: DatRoot.LogLink.pageLogTitle = "Logs"; DatRoot.LogLink.userLogTitle = "User logs"; By default the link is added before the link "What links here". To add before a different link use: DatRoot.LogLink.addBefore = Supplying the id of the element;

importScript("User:DatRoot/Scripts/Common.js");

$(function{ DatRoot.LogLink = function {   var obj = {};    if(wgNamespaceNumber >= 0) DatRoot.addOnloadHook(function {       var refElem = document.getElementById(obj.addBefore) || document.getElementById("t-whatlinkshere"); if(refElem) {           // Add the new log link before given element var htmlStrings = [ '', obj.pageLogTitle, '' ]; var logLink = DatRoot.createElement("li", "t-pagelog", "", htmlStrings.join("")); refElem.parentNode.insertBefore(logLink, refElem); }       // If logs link for user exists, rename to "User logs" var userLogLink = document.getElementById("t-log"); if(userLogLink) userLogLink.firstChild.innerHTML = obj.userLogTitle; });   obj.addBefore = "t-whatlinkshere";    obj.pageLogTitle = "Logs";    obj.userLogTitle = "User logs";    return obj; };});