Jump to content

User:Subh83/JavaScriptTools/watchistManager.js

From Wikipedia, the free encyclopedia
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.
function GenerateLinkHtml (url, text) {
    return ( "<a href=\""+url.replace(/"/g,"\\\"")+"\">" + text + "</a>");
}

if (typeof(WatchlistManager_DefaultPagetopItems)=='undefined') {
    var WatchlistManager_DefaultPagetopItems = [
                                                  [ "?title=Special:Watchlist&hideOwn=1&days=7" , "All" ] ,
                                                  [ "?title=Special:Watchlist&hideOwn=1&namespace=0&days=7" , "Articles" ] ,
                                                  [ "?title=Special:Watchlist&hideOwn=1&namespace=2&days=7" , "Self" ] 
                                               ];
}

addOnloadHook( function () {
    // Modify the "My watchlist" link at the top
    var WatchListsLI = document.getElementById('pt-watchlist');
    WatchListsLI.innerHTML = "Watchlists: [ ";
    for (var i=0; i<WatchlistManager_DefaultPagetopItems.length; i++) { 
        WatchListsLI.innerHTML += GenerateLinkHtml( wgScript+WatchlistManager_DefaultPagetopItems[i][0] , 
                                                    WatchlistManager_DefaultPagetopItems[i][1] );
        if (i < WatchlistManager_DefaultPagetopItems.length-1)
            WatchListsLI.innerHTML += ", ";
    }
    WatchListsLI.innerHTML += " ]";
});