User:Quarl/toolbox logs.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.

// [[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);
}
 
addOnloadHook(addLogsLink);
 
// </nowiki></pre>