Monchoman45

FakeTalk

Jan 26th, 2012
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function FakeTalk() {
  2.     var sub = ['Talk', 'talk']; //pages to check
  3.  
  4.     var on = false;
  5.     for(var i = 0; i < sub.length; i++) {
  6.         if(wgPageName == 'User:' + wgUserName + '/' + sub[i]) {on = true; break;}
  7.     }
  8.     if(!on) {
  9.         xhr = new XMLHttpRequest();
  10.         xhr.open('GET', '/api.php?action=query&prop=info&titles=User:' + wgUserName + '/' + sub.join('|User:' + wgUserName + '/') + '&format=json', true);
  11.         xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  12.         xhr.onreadystatechange = function() {
  13.             if(this.readyState == 4 && this.status == 200) {
  14.                 var pages = JSON.parse(this.responseText).query.pages;
  15.                 for(var i in pages) {
  16.                     if(i > 0 && pages[i].lastrevid > localStorage.getItem('msgwl_' + pages[i].title.substring(pages[i].title.indexOf('/') + 1))) {
  17.                         if(skin == 'oasis') {
  18.                             document.getElementById('WikiaFooter').getElementsByTagName('ul')[0].outerHTML += '<ul id="WikiaNotifications" class="WikiaNotifications"><li><div data-type="1"><a class="sprite close-notification"></a>You have <a href="/index.php?title=' + pages[i].title + '&redirect=no" title="' + pages[i].title + '">new messages</a>.</div></li></ul>';
  19.                         }
  20.                         else {
  21.                             document.getElementById('contentSub').outerHTML += '<div class="usermessage">You have <a href="/index.php?title=' + pages[i].title + '&redirect=no" title="' + pages[i].title + '">new messages</a> (<a href="/index.php?title=' + pages[i].title + '&diff=cur" title="' + pages[i].title + '">show most recent</a>).</div>';
  22.                         }
  23.                     }
  24.                 }
  25.             }
  26.         }
  27.         xhr.send();
  28.     }
  29.     else {localStorage.setItem('msgwl_' + wgPageName.substring(wgPageName.lastIndexOf('/') + 1), wgCurRevisionId);}
  30. }
  31. addOnloadHook(FakeTalk);
Advertisement
Add Comment
Please, Sign In to add comment