Greasy Fork is available in English.
try to take over the world!
当前为
// ==UserScript==
// @name 显示youtube好评/差评比例
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author SSmJaE
// @match https://www.youtube.com/watch?v=*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
var oldUrl;
function change() {
oldUrl = location.href;
let up = document.querySelector('[aria-label*="顶过"][id="text"]');
let down = document.querySelector('[aria-label*="踩"][id="text"]');
let upCount = up.getAttribute('aria-label');
let downCount = down.getAttribute('aria-label');
let shareButton=document.querySelector('div#info div#menu div#top-level-buttons ytd-button-renderer #text');
upCount = upCount.replace(',', '');
upCount = parseInt(upCount);
downCount = downCount.replace(',', '');
downCount = parseInt(downCount);
let ratio = Math.round(upCount * 1000 / (upCount + downCount)) / 10;
shareButton.textContent = ratio + "%";
}
function check() {
let newUrl = location.href;
if (newUrl != oldUrl) {
change();
console.log('changing');
}
}
function wait() {
setInterval(check, 5000);
console.log("wait onload");
}
window.addEventListener("load", change, false);
window.addEventListener('load', wait, false);
})();