Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// [[User:Quarl/toolbox_logs.js]] - adds relevant Logs links to Toolbox

// requires: wikipage.js, addlilink.js

// based on http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Logs_link

// adds a 'logs for this page' link to the navigation bar
// if the page is a user's page, talk page (but not subpage), the link will go to logs for the user instead
// if the page is a special page, then no link is displayed

// <pre><nowiki>

function addLogsLink() {
    var url;
    var show;
    if (relevantUser) { // defined in wikipage.js
        url = "http://en.wikipedia.org/w/index.php?title=Special:Log&user=" + relevantUser;
        show = "User " + relevantUser;
    } else if (wikiPage.nsSpecialP) {
        // don't display link for special pages (other than those with relevantUser)
        return;
    } else {
        url = "http://en.wikipedia.org/w/index.php?title=Special:Log&page=" + wikiPage.page;
        show = wikiPage.page;
    }

    var title = "Show logs for " + show;
    addToolboxLink(url, "Logs", "pt-logs", title);
}

$(addLogsLink);

// </nowiki></pre>