March of History - New Chat option

This script add some option to March of History's chat

  1. // ==UserScript==
  2. // @name March of History - New Chat option
  3. // @version 0.10
  4. // @description This script add some option to March of History's chat
  5. // @author Gohan89
  6. // @match http://www.marchofhistory.com/*
  7. // @grant none
  8. // @namespace https://greasyfork.org/users/12186
  9. // ==/UserScript==
  10.  
  11. var title = document.title;
  12. var excludedchat=new Array("Public");
  13. var num=0;
  14. function checkForChanges()
  15. {
  16. var numchat=0;
  17. $('.chatNouveauMessage').each(function(){
  18. var name=$(this).children("a").html();
  19. if(excludedchat.indexOf(name)==-1) numchat++;
  20. });
  21. if(num!=numchat){
  22. $("#numNewChat").children("a").html(numchat);
  23. num=numchat;
  24. }
  25. document.title="("+numchat+") "+title;
  26.  
  27. setTimeout(checkForChanges, 500);
  28. }
  29.  
  30. $(document).ready(function() {
  31. $(".chatListeOption").before("<li class='chatListeOption chatListeNumber ui-state-default ui-corner-top' role='tab' tabindex='-1' aria-selected='false' id='numNewChat'><a class='chatLienOption ui-tabs-anchor' role='presentation' tabindex='-1'>0</a></li>");
  32. $("#chat_onglets").css("display","Block").css("width","90%").css("overflow","auto");
  33. $(".chatListeOption").css("position","absolute").css("right","0px");
  34. $(".chatListeNumber").css("right","30px");
  35. checkForChanges();
  36. });