Hummingbird 10 Point Rating

Converts Hummingbird ratings to a 10 point scale

目前為 2014-10-11 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name                Hummingbird 10 Point Rating
// @description         Converts Hummingbird ratings to a 10 point scale
// @author              Adrien Pyke
// @version             1.2.4
// @require             https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require             https://greasyfork.org/scripts/1003-wait-for-key-elements/code/Wait%20for%20key%20elements.js?version=2765
// @include             http*://hummingbird.me/*
// @namespace https://greasyfork.org/users/649
// ==/UserScript==
function convertRatingsList(element)
{
	element = element.parent();
	var rating = element.children("span:eq(1)").text();
	element.find("i.fa-star").remove();
	element.children().hide();
	element.html(element.html() + "<span class='10point'>" + parseInt(rating * 2) + "</span>");
	element.children("span:eq(1)").bind("DOMSubtreeModified", function()
	{
		rating = element.children("span:eq(1)").text();
		element.find(".10point").text(parseInt(rating * 2));
	});
}

function convertRatingsAnime(element)
{
	var rating = element.text().substring(element.text().indexOf(":") + 1).replace(/^\s+|\s+$/g,"");//get text after colon, remove spaces.
	if (!isNaN(rating))
	{
		var newrating = rating * 2;
		element.html(element.html().replace(rating, (parseFloat(Math.round(newrating * 100) / 100).toFixed(2))));
	}
	element.bind("DOMSubtreeModified", function()
	{
		element.unbind("DOMSubtreeModified");
		setTimeout(function(){convertRatingsAnime(element);}, 100);//needs a small timeout or else it just duplicates the rating of the previous anime
	});
}

function convertRatingsColumn(element)
{
	var title = element.attr("title").split(" ");
	var rating = title[title.length - 1];
	if (!isNaN(rating))
	{
		title[title.length - 1] = parseInt(rating * 2);
	}

	element.attr("title", title.join(" "));
}

function convertRatingsReviews(element)
{
	var rating = element.children("i.fa-star").length * 2 + element.children("i.fa-star-half-o").length;
	element.html("<strong>" + rating + "</strong>");
}

function convertRatingsBreakdown(element)
{
	var score = element.find("h1.score");
	score.children().remove();
	var decimal = element.find("h5.decimal-score");
	decimal.children().remove();
	var rating = parseInt((parseFloat(score.text()) + parseFloat(decimal.text())) * 2);
	element.html("<h1 class='score' style='font-size:160px; line-height: 200px'>" + rating + "</h1>");
}

function convertRatingsVerdict(element)
{
	element.children().remove();
	element.text(parseInt(element.text() * 2));
}

waitForKeyElements("div.community-rating h5.sidebar-title", convertRatingsAnime, false);
waitForKeyElements("ul.community-rating-wrapper li.rating-column", convertRatingsColumn, false);
waitForKeyElements("span.review-stars", convertRatingsReviews, false);
waitForKeyElements("div.score-block", convertRatingsBreakdown, false);
waitForKeyElements("div.dec-score strong", convertRatingsVerdict, false);
waitForKeyElements("div.list-item-score span i.fa-star", convertRatingsList, false);