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.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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)"});
  }
});