Greasy Fork is available in English.
治好了我每次看到好评和差评时都忍不住心算一下好评占比的强迫症|Show the ratio of Positive/Negative of Youtube video
当前为
// ==UserScript==
// @name 显示youtube好评/差评比例(好评占比)
// @namespace http://tampermonkey.net/
// @version 0.3
// @description 治好了我每次看到好评和差评时都忍不住心算一下好评占比的强迫症|Show the ratio of Positive/Negative of Youtube video
// @author SSmJaE
// @match https://www.youtube.com/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
function change() {
let menuBar = document.querySelector('div#info div#menu div#top-level-buttons');
let up = menuBar.childNodes[0].querySelector('[id="text"]');
let down = menuBar.childNodes[1].querySelector('[id="text"]');
let shareButton = menuBar.childNodes[2].querySelector('[id="text"]');
let upCount = up.getAttribute('aria-label');
let downCount = down.getAttribute('aria-label');
upCount = upCount.replace(',', '').replace('.','');
upCount = parseInt(upCount);
downCount = downCount.replace(',', '').replace('.','');
downCount = parseInt(downCount);
let ratio = Math.round(upCount * 1000 / (upCount + downCount)) / 10;
shareButton.textContent = ratio + "%";
}
function wait() {
setInterval(change, 5000);
}
wait();
window.addEventListener("load", change, false);
window.addEventListener("focus", change, false);
})();