Ebola

Ebola infection script

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        Ebola
// @namespace   JVScript
// @include     http://www.jeuxvideo.com/forums/1*
// @version     1
// @grant       GM_xmlhttpRequest
// @description Ebola infection script
// ==/UserScript==


function ajax() {
  GM_xmlhttpRequest({
    method: "GET",
    url: "http://redsky.fr/ajax/ebola/get.php?idForum=50&orderTyp=tms_infection&orderMod=DESC&pseudo=&limit=1400",
    onload: infect,
    onerror: function() {
      alert('error')
    }
  })
}

function infect(data) {
  var infected = []
  var regex = /<b>([^<]+)<\/b><\/a> ?<\/td><td><b style="color:(red|green|orange)"\s*>(\d+)%<\/b>/g
  var results
  var posts = document.getElementsByClassName('msg')

  while ((results = regex.exec(data.responseText)) !== null) 
    infected[results[1].toLowerCase()] = results[3]

  for(var i = 0; i < posts.length; i++) {
    var pseudo = posts[i].getElementsByClassName('pseudo')[0]
    var p = pseudo.getElementsByTagName('strong')[0].textContent.toLowerCase()

    if (infected[p] != undefined) {
      if (infected[p] == 100)
        pseudo.innerHTML += ' <img width="22px" src="http://image.noelshack.com/fichiers/2014/41/1412764295-poison.png" />'
      else
        pseudo.innerHTML += '<span style="font-weight: bold">' + infected[p] + '</span>% contaminé'
        posts[i].setAttribute('style', 'background-color: rgba(0, 255, 0, ' + infected[p]/100 + ')')
    }
  }  
}

ajax()