Youtube Enhanced Score

YouTube likes/dislikes ratio may hold very little value on highly rated channel since ie. 94% and 96% can be a difference between bad and good video for that channel. This extension computes a logit out of likes ratio thus unbounding and centering it, so it can be more easily human interpretable.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Youtube Enhanced Score
// @description YouTube likes/dislikes ratio may hold very little value on highly rated channel since ie. 94% and 96% can be a difference between bad and good video for that channel. This extension computes a logit out of likes ratio thus unbounding and centering it, so it can be more easily human interpretable.
// @namespace   jonnyrobbie
// @include     /https?:\/\/(www\.)?(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/
// @version     1.0.1
// @grant       none
// ==/UserScript==


function main() {
	likes = getLikes();
	score = calcScore(likes);
	setScore(score);
}

function getLikes() {
	var score = {
		'likes': parseInt(document.getElementsByClassName("like-button-renderer-like-button")[0].getElementsByClassName("yt-uix-button-content")[0].innerHTML.replace(/,/g, ""), 10),
		'dislikes': parseInt(document.getElementsByClassName("like-button-renderer-dislike-button")[0].getElementsByClassName("yt-uix-button-content")[0].innerHTML.replace(/,/g, ""), 10)
	}
	return score;
}

function calcScore(likes) {
	var score = 0;
	if (likes.likes == 0 || likes.dislikes == 0) {
		score = "N/A";
	} else {
		var ratio = likes.likes / (likes.likes + likes.dislikes);
		score = Math.log(ratio) - Math.log(1-ratio); //logit
		score = score.toFixed(2);
	}
	return score;
}

function setScore(score) {
	var elScore = document.getElementsByClassName("watch-view-count")[0];
	elScore.innerHTML = elScore.innerHTML + " (" + score + ")";
}

main();