Rester's Notifications *OLD*

Rester's notifications for chat

当前为 2016-03-31 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Rester's Notifications *OLD*
  3. // @namespace arreloco
  4. // @description Rester's notifications for chat
  5. // @include http://www.kongregate.com/*
  6. // @version 0.0.1.20160331055246
  7. // ==/UserScript==
  8.  
  9. checkInfo = function(){
  10. var str = "";
  11. var user = this;
  12. user = user.active_user.getAttributes();
  13. var myMessages = new Object();
  14. myMessages = user.unread_shouts_count+user.unread_whispers_count;
  15. if (myMessages>0) {
  16. str = "...ten&eacute;s <a href=\"/accounts/"+user.username+"/messages\"> "+myMessages+(myMessages>1 ? " mensajes</a> nuevos " : " mensaje</a> nuevo");
  17. if(!/mensaje/g.test(document.getElementById("alert_box").innerHTML)){
  18. addDiv(str, "msg");
  19. }
  20. }
  21. if(!/badge/g.test(document.getElementById("alert_box").innerHTML)){
  22. var xmlhttp = new XMLHttpRequest();
  23. xmlhttp.onreadystatechange = function(){
  24. if (xmlhttp.readyState==4 && xmlhttp.status==200){
  25. x = xmlhttp.responseText;
  26. json = JSON.parse(x);
  27. last = json[json.length-1];
  28. if(last.created_at!=localStorage["lastBadge"]){
  29. str = "...hay badges nuevas en el <br><a href=\""+last.games[0].url+"\">"+last.games[0].title+"</a>";
  30. localStorage["lastBadge"] = last.created_at;
  31. }
  32. if(/badge/g.test(str)){
  33. addDiv(str, "bdg");
  34. }
  35. }
  36. }
  37. xmlhttp.open("GET","http://www.kongregate.com/badges.json",true);
  38. xmlhttp.send();
  39. }
  40. }
  41. function addDiv(str, nature) {
  42. i = document.createElement("div");
  43. i.setAttribute("style", "margin: 5px; padding: 10px; border: 2px solid #FFAAAA; border-radius: 5px; background-color: #FFEEEE; top:-10px; ");
  44. i.innerHTML = "<b>Arre que...</b><br>"+str;
  45. alert_box = document.getElementById("alert_box");
  46. alert_box.appendChild(i);
  47. }
  48. setInterval(checkInfo, 20000);
  49. setTimeout(function(){container = document.createElement("div"); container.setAttribute("id","alert_box"); container.setAttribute("style", "color: #440000; font-size:12px; position: fixed; width: 17%; text-align: left; top: 80%; left: 80%;"); document.getElementsByTagName('body')[0].appendChild(container);},5000);