Ebola

Ebola infection script

  1. // ==UserScript==
  2. // @name Ebola
  3. // @namespace JVScript
  4. // @include http://www.jeuxvideo.com/forums/1*
  5. // @version 1
  6. // @grant GM_xmlhttpRequest
  7. // @description Ebola infection script
  8. // ==/UserScript==
  9.  
  10.  
  11. function ajax() {
  12. GM_xmlhttpRequest({
  13. method: "GET",
  14. url: "http://redsky.fr/ajax/ebola/get.php?idForum=50&orderTyp=tms_infection&orderMod=DESC&pseudo=&limit=1400",
  15. onload: infect,
  16. onerror: function() {
  17. alert('error')
  18. }
  19. })
  20. }
  21.  
  22. function infect(data) {
  23. var infected = []
  24. var regex = /<b>([^<]+)<\/b><\/a> ?<\/td><td><b style="color:(red|green|orange)"\s*>(\d+)%<\/b>/g
  25. var results
  26. var posts = document.getElementsByClassName('msg')
  27.  
  28. while ((results = regex.exec(data.responseText)) !== null)
  29. infected[results[1].toLowerCase()] = results[3]
  30.  
  31. for(var i = 0; i < posts.length; i++) {
  32. var pseudo = posts[i].getElementsByClassName('pseudo')[0]
  33. var p = pseudo.getElementsByTagName('strong')[0].textContent.toLowerCase()
  34.  
  35. if (infected[p] != undefined) {
  36. if (infected[p] == 100)
  37. pseudo.innerHTML += ' <img width="22px" src="http://image.noelshack.com/fichiers/2014/41/1412764295-poison.png" />'
  38. else
  39. pseudo.innerHTML += '<span style="font-weight: bold">' + infected[p] + '</span>% contaminé'
  40. posts[i].setAttribute('style', 'background-color: rgba(0, 255, 0, ' + infected[p]/100 + ')')
  41. }
  42. }
  43. }
  44.  
  45. ajax()