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.

  1. // ==UserScript==
  2. // @name OSRS - Accurate Polls
  3. // @namespace OSRSAccuratePolls
  4. // @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.
  5. // @include *runescape.com/m=poll/*results.ws?id=*
  6. // @version 1.1
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. $("fieldset.question").each(function() {
  11. yesText = $("table tbody tr:first-of-type td:last-of-type", this).text();
  12. noText = $("table tbody tr:nth-of-type(2) td:last-of-type", this).text();
  13. skipText = $("table tbody tr:nth-of-type(3) td:last-of-type", this).text();
  14. yesSplit = yesText.split("(");
  15. yesVotes = parseInt(yesSplit[1].split(" votes)"));
  16. noSplit = noText.split("(");
  17. noVotes = parseInt(noSplit[1].split(" votes)"));
  18. skipSplit = skipText.split("(");
  19. skipVotes = parseInt(skipSplit[1].split(" votes)"));
  20. totalVotes = +yesVotes + +noVotes;
  21. yesPercent = (100 / totalVotes) * yesVotes;
  22. noPercent = (100 / totalVotes) * noVotes;
  23. $("table tbody tr:first-of-type td:last-of-type", this).text(yesPercent.toFixed(4) + "% (" + yesVotes + " votes)");
  24. $("table tbody tr:nth-of-type(2) td:last-of-type", this).text(noPercent.toFixed(4) + "% (" + noVotes + " votes)");
  25. $("table tbody tr:nth-of-type(3) td:last-of-type", this).text(skipVotes + " votes");
  26. $("table colgroup col:first-of-type", this).width("30%");
  27. if(yesPercent >= 75) {
  28. $(this).css({"background": "rgba(0, 255, 0, 0.2)"});
  29. } else {
  30. $(this).css({"background": "rgba(255, 0, 0, 0.2)"});
  31. }
  32. });