Greasy Fork 还支持 简体中文。

IMDB - share vote on Facebook, Twitter, Tumblr

Adds links to IMDB title pages that let you share your vote details on Facebook and/or Twitter

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.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

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 - share vote on Facebook, Twitter, Tumblr
// @namespace		https://greasyfork.org/en/users/7864-curtis-gibby
// @description		Adds links to IMDB title pages that let you share your vote details on Facebook and/or Twitter
// @grant			none
// @version			2.0.11
// @include			http://*.imdb.com/title/*/*
// @include			http://*.imdb.com/title/*/#*
// @include			http://*.imdb.com/title/*/combined*
// @include			http://*.imdb.com/title/*/maindetails*
// @include			http://imdb.com/title/*/*
// @include			http://imdb.com/title/*/#*
// @include			http://imdb.com/title/*/combined*
// @include			http://imdb.com/title/*/maindetails*
// ==/UserScript==

if ($('.giga-star .rating-rating .value').length > 0) {
	var voteValue = parseInt($('.giga-star .rating-rating .value').html());
} else if ($('#voteuser').length > 0) {
	var voteValue = parseInt($('#voteuser').html());
} else {
	var voteValue = $('#star-rating-widget').data('rating');
}

// only put it in if they've voted
if (typeof voteValue == 'number' && voteValue > 0) {
	var shareFacebookUrl;
	var twitterImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AsNEQUexbZYjwAAAcNJREFUOMvFU0tLG1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Q3DAFdDAAAAAElFTkSuQmCC";
	var tumblrImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AsNEQgzNcd6twAAAfNJREFUOMulk81rE1EUxX93pjFxoRisHwTy0RAtbaBmUVolKEggoXUliohCstAOEuqm7lwI/gNCsboYXKgLXboplgZEQSxFN0awCMViTCk2xLaxm9pk5rnQxmQ6QsGzeu/d8869791zBQeSmVy8AVfBTqMIASB8Ba3QAQ/eTD/62MqXrYVhGJ4PpY07NuRRSsMNIrYG9/vCvjHTNOtNAcMwPO9LG1MolWInEHmRCPuGTNOs6wCezvi4UupiK6e3O8rkk3H8+/Yw87bolIhWapZ/8XNxSktmcnEb8k5G6uQAALquuxZhQz6ZycX1QCxxE6VObAW83l2MXrnA5fPDAOz2eolFg6zV1qlUV9seokQ2NbDTraddoQCXzg0195FQgLPDp4mEAm51pLVmq/5gfqFMbvQWleoKAM+ev2Qwk2Wy8Hr7fUVoW7ssy+LT/Bfq9cZOuqG03yZxEVeq3SiuUGUNtIJb6FvlOwDdRyI8nLhNz9EuF5ZW0COxxKItXHMmq66skjo1wOGDnRzY76dhWe1+ELE9yIgAHM9k79pKjTr1g4FD9Cd6+blZZ+ZdkbXa+t/cIhOz04+vdwAE90ZvlH4s9DitXF5apry07GrlvrBvbBbQAebmXllnUoNPKzXLr0T6//l3IrYmcu9Y2JdtG6b/GedfoZmyJzVJQI4AAAAASUVORK5CYII=";
	var movieName = getMovieName();
	var imdbUrl = "http://www.imdb.com/title/tt" + getIMDBid();

	var shareFacebookUrl = 'http://www.facebook.com/dialog/feed?app_id=216735281691205&link='+imdbUrl+'&caption=My rating%3A ' + voteValue + '/10&redirect_uri=' + imdbUrl + getMovieImageUrl();
	var shareTumblrUrl = 'http://www.tumblr.com/share?v=3&u=' + escape(imdbUrl) + '&t=&s=I%20gave%20the%20film%20' + escape(movieName.replace(/&/, '%26')) + '%20a%20rating%20of%20' + voteValue + '/10%20on%20IMDb.';
	var shareTwitterUrl = 'http://twitter.com/intent/tweet?url='+ escape(imdbUrl) + '&text=gave the film %22' + escape(movieName.replace(/&/, '%26')) + '%22 a rating of ' + voteValue + '/10 on %23IMDb';

	addedDivFBLink = $('<div></div>');
	addedDivFBLink.html('Share your vote: <a title="Share on Facebook" target="_blank" href=\'' + shareFacebookUrl + '\'><img src="' + facebookImage + '" alt="Share on Facebook"></a> <a target="_blank" id="GM_twitter_link" title="Share on Twitter" href=\'' + shareTwitterUrl + '\'><img src="' + twitterImage + '" alt="Share on Twitter"></a> <a target="_blank" title="Share on Tumblr" href=\'' + shareTumblrUrl + '\'><img src="' + tumblrImage + '" alt="Share on Tumblr"></a>');
	addedDivFBLink.attr('id','GM_ShareVoteOnFacebook');

	var insertSelector = "div.star-box";

	if ($('table.probody').length > 0) {
		insertSelector = "table.probody";
	}

	if ($('#tn15').length > 0) {
		insertSelector = "div.info:first";
	}

	if ($('.plot_summary_wrapper').length > 0) {
		insertSelector = ".plot_summary_wrapper";
	}

	if ($('#tn15rating .personal').length > 0) {
		insertSelector = '#tn15rating .personal';
	}
	unsafeWindow.console.log("insertSelector : ", insertSelector); //debug!
	$(insertSelector).append(addedDivFBLink);
}

function getIMDBid() {
	var regexImdbNum = /\/title\/tt(\d{7})\//;
	id = regexImdbNum.exec(document.location);
	return id[1];
}

function getMovieName() {
	var rawTitle = $('meta[property="og:title"]').attr('content');
	var temp = rawTitle.match(/\([^()]*\)/g).pop();
	var year = temp.substr(1, temp.length - 2);
	var title = rawTitle.substr(0, rawTitle.indexOf(temp) - 1);
	return title;
}

function getMovieImageUrl() {
	findPattern = '//td[@id="img_primary"]/div[@class="image"]/a/img[@itemprop="image"]';
	imageResults = document.evaluate( findPattern, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );

	if (imageResults.snapshotItem(0) != null) {
		return '&picture=' + encodeURI(imageResults.snapshotItem(0).src); // debug!
	}
	else {
		return '';
	}
}