IMDb rating sanitiser.

Replaces rating on IMDb title pages with Non-US user rating.

目前為 2014-07-19 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        IMDb rating sanitiser.
// @namespace   dicks
// @description Replaces rating on IMDb title pages with Non-US user rating.
// @include     http*://*.imdb.com/title/tt*
// @include     http*://imdb.com/title/tt*
// @version     0002
// @require     https://code.jquery.com/jquery-2.1.1.min.js
// ==/UserScript==
function main(url, combined) {
    $.ajax({
        url: url + 'ratings-international',
        success: function (data) {
            var line = $(data).find('#tn15content').find('p').eq(0).text();
            if (!line) {
                return false;
            }

            var realvotes = line.match(/^(\d+) Non-US users/)[1].replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' non-US ',
                realscore = line.match(/vote of (\d+\.?\d*) \/ 10/)[1];

            if (!combined) {
                var star = $('.star-box-giga-star').eq(0),
                    text = $('.star-box-details').eq(0).find('span'),
                    rate = text.eq(0),
                    vote = text.eq(3);
            } else {
                var star = $('#general-voting-stars'),
                    rate = $('.starbar-meta').find('b').eq(0),
                    vote = $('.tn15more').eq(0);
            }

            star.fadeOut(400);
            rate.fadeOut(400);
            vote.fadeOut(400);
            setTimeout(function () {
                if (!combined) {
                    star.text(realscore);
                } else {
                    star.width((realscore * 20));
                }
                rate.text(realscore + (combined ? '/10' : ''));
                vote.text(realvotes + (combined ? 'votes' : ''));
            }, 400);
            star.fadeIn(400);
            rate.fadeIn(400);
            vote.fadeIn(400);
        }
    });
}

combined = (location.href.match(/\/combined\/?/)) ? true : false;
url = location.href.replace(/(combined\/?|\?ref_=).*/g, '');
if (url.match(/\/title\/tt\d{7,}\/$/)) {
    main(url, combined);
}