Hummingbird 10 Point Rating

Converts Hummingbird ratings to a 10 point scale

当前为 2014-10-20 提交的版本,查看 最新版本

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

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 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.5
// @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)) {
		element.get(0).childNodes[2].textContent = Number(rating * 2).toFixed(2);
	}
    element.bind("DOMSubtreeModified", function(){
        element.unbind("DOMSubtreeModified");
        convertRatingsAnime(element);
    });
}

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);