Greasy Fork

Greasy Fork is available in English.

IMDb Face Cake - get a better look at actor images

Make people's faces larger when you hover over their names on IMDb title pages

当前为 2015-09-20 提交的版本,查看 最新版本

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

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

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

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

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

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        IMDb Face Cake - get a better look at actor images
// @namespace   driver8.net
// @description Make people's faces larger when you hover over their names on IMDb title pages
// @match       *://*.imdb.com/title/tt*/reference*
// @match       *://*.imdb.com/title/tt*/
// @match       *://*.imdb.com/title/tt*/?*
// @match       *://*.imdb.com/name/nm*
// @match       *://*.imdb.com/title/tt*/fullcredits*
// @version     0.3.1
// @grant       GM_addStyle
// @require     https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
// ==/UserScript==

var MULT = 8;
var IMG_WIDTH = 23 * MULT;
var IMG_HEIGHT = 30 * MULT;
var OFFSET_TOP = -40;
var OFFSET_LEFT = -6;
//var OFFSET_BOTTOM = 94;
var OFFSET_BOTTOM = 2;
var THUMB_OFFSET = -200; // -275
var OFFSET_MULTIPLIER = 0;
var IMDB_WIDTH = 640;
var IMDB_HEIGHT = 720;
var LEFT_SIDE = true;
var LOGGING = false;
var AND_BUTTS = false;

function log(msg) {
    if (LOGGING) console.log(msg);
}

AND_BUTTS && $('#tn15title > h1 > span:first').before($('<h1> and Butts </h1>').css({'display': 'inline'}));

var bigDivs = [];
var thumbDivs = [];
var unloadedImage = 0;

//var $rows = $('table.cast tr.odd, table.cast tr.even');
var $rows = $('table.cast, table.cast_list').find('tr.odd, tr.even');
var $thumbs = $('.media_strip_thumb img, .mediastrip img, .mediastrip_big img, #primary-poster, .photo img');

function setUpRows(start) {
    $rows.each(function(idx) {
        if (idx >= start) {
            return makePopup(idx, $(this));
        }
    });
}

function makePopup(idx, $el) {
    var $hovaImg, $hovaDiv;
    var $hsImg = $el.find('td.hs img, td.primary_photo img');
    var hsSrc = $hsImg.attr('src');
    if ($hsImg.hasClass("loadlate") && $hsImg.attr('src').match(/\/imdb\/images\/nopicture\//)) {
        //$hsImg.on('appear', function () {
        //    makePopup(idx, $el);
        //});
        hsSrc = $hsImg.attr('loadlate');
    }
    hsSrc = hsSrc.replace(/http:\/\/ia\.media-imdb\.com\/images\/([a-zA-Z0-9@]\/[a-zA-Z0-9@]+)\._V[0-9].+\.jpg/,
        'http://ia.media-imdb.com/images/$1._SX' + IMG_WIDTH + '_.jpg');
    $hovaImg = $('<img>').attr('src', hsSrc);
    $hovaDiv = $('<div></div>');
    $hovaDiv.append($hovaImg);
    $hovaDiv.attr('id', 'hova' + idx);
    $hovaDiv.addClass('hovaImg');
    var pos = $el.offset();
    var newPos = { 'top': pos.top + OFFSET_TOP, 'left': pos.left + OFFSET_LEFT - IMG_WIDTH };
    if (!LEFT_SIDE) {
        var trWidth = $el.outerWidth();
        newPos = { 'top': pos.top + OFFSET_TOP, 'left': pos.left - OFFSET_LEFT + trWidth };
    }
    $hovaDiv.offset(newPos);
    $hovaDiv.hide();
    $('body').append($hovaDiv);
    bigDivs[idx] = $hovaDiv;
}

function setUpThumbs() {
    $thumbs.each(function(idx) {
        var $el = $(this);
        var thumbSrc = $el.attr('src');
        thumbSrc = thumbSrc.replace(/http:\/\/ia\.media-imdb\.com\/images\/([a-zA-Z0-9@]\/[a-zA-Z0-9@]+)\._V[0-9].+\.jpg/,
            'http://ia.media-imdb.com/images/$1._V1_SX' + IMDB_WIDTH + '_SY' + IMDB_HEIGHT + '_.jpg');
        var $hovaImg = $('<img>').attr('src', thumbSrc);
        var $hovaDiv = $('<div></div>').append($hovaImg).attr('id', 'hovat' + idx).addClass('hovaThumb');
        var pos = $el.offset();
        var height = $el.outerHeight();
        var newPos = { 'top': pos.top + height + OFFSET_BOTTOM, 'left': pos.left + THUMB_OFFSET + idx * OFFSET_MULTIPLIER };
        $hovaDiv.offset(newPos);
        $hovaDiv.hide();
        $('body').append($hovaDiv);
        thumbDivs[idx] = $hovaDiv;
    });
}

$rows.each(function(idx) {
    var $el = $(this);
    $el.mouseenter(function() {
        $el.addClass('trHova');
        //var $image = $el.find("td.primary_photo img");
        if (!bigDivs[idx]) {
            setUpRows(unloadedImage);
        }
        bigDivs[idx].show();
    });

    $el.mouseleave(function() {
        $el.removeClass('trHova');
        bigDivs[idx].hide();
    });
});

$thumbs.each(function(idx) {
    var $el = $(this);
    $el.mouseenter(function() {
        if (!thumbDivs[idx]) {
            setUpThumbs();
        }
        thumbDivs[idx].show();
    });

    $el.mouseleave(function() {
        thumbDivs[idx].hide();
    });
});

var userStyles =
    ".hovaImg, .hovaThumb { " +
    "position: absolute;" +
    "padding: 0px;" +
    "border-style: solid;" +
    "border-width: 2px;" +
//        "border-color: #00FF00;" +
    "border-color: #AAAAFF;" +
    "z-index: 4;" +
    "}" +
    ".hovaImg img {" +
    "width: " + IMG_WIDTH + "px;" +
    "display: block;" +
    "}" +
    ".hovaThumb img { display: block; }" +
    "tr.trHova {" +
    "background-color: #AAAAFF !important;" +
    "}" +
    "div#tn15content div.info div.info-content.block {" +
    //"width: 90% !important;" +
    "}" +
    //"td.hs img {" +
    //"height: auto !important;" +
    //"width: auto !important;" +
    //"max-width: 23px !important;" +
    //"max-height: 32px !important;" +
    //"}" +
    "";

GM_addStyle(userStyles);