Displays the number of up/down votes on Reddit
目前為
// ==UserScript==
// @name Reddit Up/Down Votes
// @namespace https://www.reddit.com/user/XxBobTheZealotxX
// @version 1.0
// @description Displays the number of up/down votes on Reddit
// @author XxBobTheZealotxX
// @match https://www.reddit.com/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// ==/UserScript==
$(document).ready(function() {
var interval = window.setInterval(intervalFunction, 2000);
function intervalFunction() {
if ($("[data-test-id='post-content']").length == 0) {
return;
}
var root = $("[data-test-id='post-content']").first();
var percUpvotedElement = root.children().eq(3).children().eq(1);
if (!percUpvotedElement.text().includes("%")) {
return;
}
var scoreElement = root.children().first().children().first().children().eq(1);
var score = parseInt(scoreElement.text());
var percUpvoted = parseFloat(percUpvotedElement.text().split("%")[0]) * 0.01;
var up = Math.round((percUpvoted * score) / (percUpvoted * 2 - 1));
var down = up - score;
percUpvotedElement.text(up + " Up / " + down + " Down");
}
});