IMDB+

Add external links to IMDb. Every feature can be enabled/disabled in settings.

Ajankohdalta 19.7.2014. Katso uusin versio.

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        IMDB+
// @namespace   imdb.com
// @description Add external links to IMDb. Every feature can be enabled/disabled in settings.
// @include     http://www.imdb.com/title/tt*
// @require     https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// @grant       GM_getValue
// @grant       GM_setValue
// @grant       GM_addStyle
// @version     1.0.1
// ==/UserScript==

jQuery(document).ready(function($) {
var m	= {};
m.Id	= getMovieId();
m.Tt	= getMovieTt();
m.TtYr	= "%22" + getMovieTt() + "%22+" + getMovieYr();

var l = {};
l.rut	= ["RuTracker", "http://rutracker.org/forum/tracker.php?nm=" + m.TtYr, "http://rutracker.org/favicon.ico"];
l.yt	= ["Youtube", "http://www.youtube.com/results?search_query=" + m.TtYr, "http://www.youtube.com/favicon.ico"];
l.kp    = ["Kinopoisk", "http://www.kinopoisk.ru/index.php?first=yes&kp_query=" + m.Tt, "http://st.kp.yandex.net/images/favicon.ico"];
l.all	= ["allMovie", "http://www.allmovie.com/search/movies/" + m.TtYr, "http://www.allmovie.com/favicon.ico"];

// Functions
function getMovieId() {
var id = location.pathname.match(/title\/tt(.*?)\//i)[1];
return id;
}

function getMovieTt() {
var title = document.title.replace(/^(.+) \((.*)([0-9]{4})(.*)$/gi, '$1');
return encodeURIComponent(title);
}

function getMovieYr() {
var year = document.title.replace(/^(.+) \((.*)([0-9]{4})(.*)$/gi, '$3');
return encodeURIComponent(year);
}

function IMDbPlusStyle() {
var s =
'#title-overview-widget #IMDbPlus { padding: 5px 0 0 230px; }' +
'#title-overview-widget #IMDbPlus a { margin: 5px 1px; }' +
'#title-overview-widget #IMDbPlus #IMDbPlus-Feature-Settings { margin-left: 10px; }' +
'#action-box #IMDbPlus #IMDbPlus-Feature-Settings { margin-top: 10px; }' +

'#IMDbPlus-SettingsBox { display: none; margin-left: -404px; padding: 20px; position: fixed; top: 10%; left: 50%; width: 768px; z-index: 999; }' +
'#IMDbPlus-SettingsBox > h2 { font-size: 21px }' +
'#IMDbPlus-SettingsBox > h4 { font-size: 15px }' +
'#IMDbPlus-SettingsBox #IMDbPlus-Options { margin: 20px 0;}' +
'#IMDbPlus-SettingsBox #IMDbPlus-Options .IMDbPlus-OptionField label { display: inline-block; width: 150px; }' +
'#IMDbPlus-SettingsBox button { margin: 8px 0 0; }' +
'#IMDbPlus-SettingsBox #IMDbPlus-SettingsBox-Close { float: right; }';
GM_addStyle(s);
}

function IMDbPlusInit() {
var fh, oh;
fh = '<div id="IMDbPlus"><hr><h4>IMDB++ Features:</h4>';
oh = '<div id="IMDbPlus-SettingsBox" class="aux-content-widget-2"><h2>IMDb++ Options</h2><h4>Control the features you want to show</h4><ul id="IMDbPlus-Options">';

$.each(l, function(key,val) {
if (GM_getValue("IMDbPlus-Option-" + val[0], 1)) {
fh += '<a class="IMDbPlus-Button linkasbutton-secondary" id="IMDbPlus-Feature-' + val[0] + '" href="' + val[1] + '" target="_blank" title="' + val[0] + '"><img alt="' + val[0] + '" src="' + val[2] + '" width="16" height="16"></a>';
}
oh += '<li id="IMDbPlus-Option-' + val[0] + '-Field" class="IMDbPlus-OptionField"><label for="IMDbPlus-Option-' + val[0] + '">' + val[0] + '</label> <input id="IMDbPlus-Option-' + val[0] + '" type="checkbox"' + ((GM_getValue("IMDbPlus-Option-" + val[0], 1)) ? ' checked' : '') + '></li>';
});

fh += '<a class="IMDbPlus-Button linkasbutton-secondary" id="IMDbPlus-Feature-Settings" title="Open settings frame"><img alt="Settings" src="http://i.imgur.com/j9VseXa.png"></a></div>';
oh +=
'</ul><hr>' +
'<button id="IMDbPlus-SettingsBox-Save" class="primary">Save</button>' +
'<button id="IMDbPlus-SettingsBox-Close" class="primary">Close</button>' +
'</div>';

IMDbPlusStyle();

$((location.pathname.match(/combined/)) ? '#action-box' : '#title-overview-widget').append(fh);
$('body').append(oh);
}

IMDbPlusInit();

function showOpts() {
$('#wrapper').css('visibility', 'hidden').animate({ opacity: 0 }, 500);
$('#IMDbPlus-SettingsBox').show(500);
}

function hideOpts()     {
$('#IMDbPlus-SettingsBox').hide(500);
$('#wrapper').css('visibility', 'visible').animate({ opacity: 1 }, 500);
}

function saveOpts() {
$('.IMDbPlus-OptionField').each(function() {
var
inputElm = $('input', this),inputId  = inputElm.attr('id');
GM_setValue(inputId, (inputElm.is(":checked") ? 1 : 0));
});
hideOpts();
window.location.reload();
}

// Interactions
$('#IMDbPlus-Feature-Settings').click(showOpts);
$('#IMDbPlus-SettingsBox-Close').click(hideOpts);
$('#IMDbPlus-SettingsBox-Save').click(saveOpts);

$(document).keyup(function(e) {
if(e.keyCode == 27) {
hideOpts();
}
});
});