Jump to content

User:Greg Tyler/newmessage.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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.
// Hide the default box and add our own
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);


// You can have whatever you want here
function newMessageAlert() {
    // A personal default: "my talk" goes bold
    document.getElementById('pt-mytalk').style.fontWeight = "bold";
    // For those who need to keep track, an alert box
    alert("You have new unread messages!");
    // Want a tab for this?
    addPortletLink( 'p-cactions', "http://en.wikipedia.org/wiki/Special:MyTalk", "new", "gt-new", "You have new messages on your talk page!", "");
}