Greasy Fork

Greasy Fork is available in English.

显示youtube好评/差评比例(好评占比)

治好了我每次看到好评和差评时都忍不住心算一下好评占比的强迫症|Show the ratio of Positive/Negative of Youtube video

当前为 2020-03-29 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);
})();