User:Quarl/newmessages.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/newmessages.js]] - annotate the "You have new messages" alert // to add "diff since" and "hist" links. // requires: wikipage.js, diffsince.js, util.js // quarl 2006-01-16 initial version // <pre><nowiki> var newmessages = new Object(); newmessages._load = function() { var talkmessagebox = getElementsByClass('usermessage',document.getElementById('bodyContent'),'div')[0]; if (!talkmessagebox || talkmessagebox.textContent != "You have new messages (diff).") return; newmessages.wpTalk = new WikiPage(null,'User talk:' + wikiDoc.username); var histUrl = newmessages.wpTalk.qurl + '&action=history'; var diffSinceUrl = diffsince.makeUrl(newmessages.wpTalk); talkmessagebox.className += ' plainlinks'; var t = (' (<span id="newmessages-diffsince">' + '<a onclick="javascript:return newmessages.diffSince()" href="'+diffSinceUrl+'">' + 'diff since</a></span>)' + ' (<a href="'+histUrl+'">history</a>)'); // insert before final period talkmessagebox.innerHTML = talkmessagebox.innerHTML.replace(/(?=[.]$)/, t); } newmessages.diffSince = function() { return diffsince.diffPageAsync(newmessages.wpTalk, document.getElementById('newmessages-diffsince'), '<b>diff since...</b>'); } addOnloadHook(newmessages._load); // </nowki></pre></nowiki></pre>

