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.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

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