// ==UserScript==
// @name          Hatena Question Dishonest Checker
// @include       http://q.hatena.ne.jp/*
// @namespace     http://www.bulkitem.com/userscript/hatena/
// @description   Hatena Question
// @version       0.1.1
// ==/UserScript==

(function() {
  var rows = document.getElementsByClassName('countcell');
  for (var i=0; i<rows.length; i++) {
    var td = rows[i].parentNode.getElementsByTagName('td');
    if (Number(td[2].textContent) == 0) {
        td[2].style.backgroundColor = '#FFF68F';
        td[3].style.backgroundColor = '#FFF68F';
        td[4].style.backgroundColor = '#FFF68F';
        continue;
    }
    var accept_rate = Math.round(Number(td[3].textContent) / Number(td[2].textContent) * 10000) / 100;
    var iruka_rate = Math.round(Number(td[4].textContent) / Number(td[2].textContent) * 10000) / 100;
    td[3].innerHTML = td[3].textContent + ' (' + accept_rate.toString() +'%)';
    td[4].innerHTML = td[4].textContent + ' (' + iruka_rate.toString() + '%)';
    if (accept_rate < 80) { td[3].style.backgroundColor = '#FFC0CB'; }
    if (accept_rate >= 90) { td[3].style.backgroundColor = '#C1FFC1'; }
    if (iruka_rate >= 10) { td[4].style.backgroundColor = '#C1FFC1'; }
    if (iruka_rate == 0) { td[4].style.backgroundColor = '#FFF68F'; }
  }
})();

