Utilisateur:Creasy/AdvancedContribsAdds.js

Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;

Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.
/*
 * Dans l'outil AdvancedContribs, afficher ma page utilisateur en surbrillance orange.
 * */

var myTalkPage = "Discussion utilisateur:Creasy";

var userTalkHighlight = function() {
    // if list isn't build, an error can occurs
    try {
        // select list of contribs main div
        contribContent = document.getElementById('contribContent');

        // list of a tags in contribContent
        aTagList = contribContent.getElementsByTagName('a');

        // search my userTalk page
        for (i=0; i<aTagList.length; i++) {
            if (aTagList[i].title == myTalkPage) {
                userTalkRow = aTagList[i].parentNode.parentNode;
                // Only one line 'myTalkPage' so leave when done
                break;
            }
        }
    } catch(e) {
        // new try five seconds later
        setTimeout(userTalkHighlight, 5000);
        return
    }

    // if no line match the searched one, do not restart
    if (typeof userTalkRow === "undefined") {
        return
    } else {
        // change background of matched line
        userTalkRow.style.backgroundColor = "#FFBB33";
        return
    }
}

var onClickRefresh = function() {
    $('#btn_reload').bind('click', function() {
        // wait a second to try highlight
        setTimeout(userTalkHighlight, 1000);
    });
}

if (document.location.pathname === "/wiki/Utilisateur:Maloq/AdvancedContribs") {
    $(document).ready(function() {
        userTalkHighlight();
        // after two seconds, add update the onclick attribute of refresh button
        setTimeout(onClickRefresh, 2500);
    });
}