OSRS - Accurate Polls

Gives more accurate results to Old School RuneScape polls, including decimals in vote percentages, and colour-coded to show what's passing and failing.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        OSRS - Accurate Polls
// @namespace   OSRSAccuratePolls
// @description Gives more accurate results to Old School RuneScape polls, including decimals in vote percentages, and colour-coded to show what's passing and failing.
// @include     *runescape.com/m=poll/*results.ws?id=*
// @version     1.1
// @grant       none
// ==/UserScript==

$("fieldset.question").each(function() {
  yesText = $("table tbody tr:first-of-type td:last-of-type", this).text();
  noText = $("table tbody tr:nth-of-type(2) td:last-of-type", this).text();
  skipText = $("table tbody tr:nth-of-type(3) td:last-of-type", this).text();
  yesSplit = yesText.split("(");
  yesVotes = parseInt(yesSplit[1].split(" votes)"));
  noSplit = noText.split("(");
  noVotes = parseInt(noSplit[1].split(" votes)"));
  skipSplit = skipText.split("(");
  skipVotes = parseInt(skipSplit[1].split(" votes)"));
  totalVotes = +yesVotes + +noVotes;
  yesPercent = (100 / totalVotes) * yesVotes;
  noPercent = (100 / totalVotes) * noVotes;
  $("table tbody tr:first-of-type td:last-of-type", this).text(yesPercent.toFixed(4) + "% (" + yesVotes + " votes)");
  $("table tbody tr:nth-of-type(2) td:last-of-type", this).text(noPercent.toFixed(4) + "% (" + noVotes + " votes)");
  $("table tbody tr:nth-of-type(3) td:last-of-type", this).text(skipVotes + " votes");
  $("table colgroup col:first-of-type", this).width("30%");
  if(yesPercent >= 75) {
    $(this).css({"background": "rgba(0, 255, 0, 0.2)"});
  } else {
    $(this).css({"background": "rgba(255, 0, 0, 0.2)"});
  }
});