User:Greg Tyler/New message alerter

My "New message alerter" replaces the traditional box stating "you have new messages" with an interaction of your choice! It's easy to set up and has all sorts of possibilities. To set it up, navigate to your monobook.js and copy the following code into it:

addEventListener('DOMContentLoaded',function { d = document.getElementsByTagName('div'); for(i=0;i<d.length;i++) {   if(d[i].innerHTML.substr(0,8)=='You have') {d[i].style.display="none";newMessageAlert;} } }, false);

function newMessageAlert { // ENTER FUNCTION HERE }

This code hides the default box and then asks what to do instead. If you're JavaScript-savvy, you can just change the newMessageAlert function, if not, see the section below.

A supply of alternatives
To add these, simply copy and paste them to a new line after the one that says. For example, adding the first code snippet would give you:

function newMessageAlert { // ENTER FUNCTION HERE document.getElementById('pt-mytalk').style.fontWeight = "bold"; }

If you want something different to happen, add it to the talk page and I'll add the code here. Otherwise, here are some code snippets for you:


 * Make "my talk" bold
 * document.getElementById('pt-mytalk').style.fontWeight = "bold";

(change "red" to whatever colour you please)
 * Change "my talk" to a different colour
 * document.getElementById('pt-mytalk').style.color = "red";

(this can be anything else, of course, if you change the text)
 * Change "my talk" to "my talk (new)"
 * document.getElementById('pr-mytalk').getElementsByTagName('a')[0].innerHTML = "my talk (new)";


 * Throw up a popup box
 * alert("You have new unread messages!");


 * Add a tab next to "watch" called "new" which links to your talk page
 * addPortletLink( 'p-cactions', "http://en.wikipedia.org/wiki/Special:MyTalk", "new", "ca-gt-new", "You have new messages on your talk page!", "");


 * Similarly, add a link in the toolbox
 * addPortletLink( 'p-tb', "http://en.wikipedia.org/wiki/Special:MyTalk", "New messages", "tb-gt-new", "You have new messages on your talk page!", "");