THIS IS A STATIC MIRROR OF USERSCRIPTS.ORG - LOGINS DO NOT WORK

IMDB - share vote on Facebook, Twitter, Tumblr - TURKISH

By haluk Last update Apr 4, 2011 — Installed 447 times.

There are 1 previous version of this script.

// ==UserScript==
// @name			IMDB - share vote on Facebook, Twitter, Tumblr - Turkish
// @description		Adds links to IMDB title pages that let you share your vote details on Facebook and/or Twitter turkish version
// @version			1.6
// @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==

// ==User-Defined Variables==

//shortenTwitterUrl = false;
shortenTwitterUrl = true; // use the bit.ly API to create a short URL like http://imdb.to/jI6bw

bitlyLogin = 'shorter'; // customize for your own bit.ly API login details
bitlyKey = 'R_2546703adeade4dc850d14825242f183';

// ==/User-Defined Variables==

findPattern = "//span[@class='rating-rating rating-your']";
voteResults = document.evaluate( findPattern, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );

// only put it in if they've voted
if (voteResults.snapshotItem(0) != null && voteResults.snapshotItem(0).innerHTML != "") {

	var shareFacebookUrl;
	var twitterImage = "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%16%00%00%00%16%08%06%00%00%00%C4%B4l%3B%00%00%00%04sBIT%08%08%08%08%7C%08d%88%00%00%00%09pHYs%00%00%0A%F0%00%00%0A%F0%01B%AC4%98%00%00%00%16tEXtCreation%20Time%0011%2F14%2F09%BF%DE%EA%09%00%00%00%1CtEXtSoftware%00Adobe%20Fireworks%20CS4%06%B2%D3%A0%00%00%02sIDAT8%8D%A5%94%BFN%1BA%10%87%BF%D9%BD%BF6%96%12%D9%08R%40%104%E9%E9x%00%FA%BC%01%E9%C2%03Di%A1%23R%DA%94(y%03%5E%C4M%9AH)%EC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AC%18%CE9%7C%DFG%0B%9C%7C%FD%C2%9F_%1D%06%FD~%09x%D3K%B8%BC8%E7%F7%C5%19%93%8C%A9%8A%EFT%87a%08%C0%E5%F9%0F%CEO%BE%15%F5%2Fv%A55a%18%12%C71%222%B5%8FO%AD%B5%2B%93w%5DD%08%82%00%AD5Q%14%95%AE%BAR%0A%AD5Z%EB%E2%A1%1F%11y%EA%01%07%FD~%FF%83%EF%FB%A5%87%04(%82%1F%B2I%A81%06%E0%C0%03%0E%8D1b%8Cy%2B%22%2B%0F%12%E60%E7%DC)%F0%0E8%FC%07%D1%F9%B9%E7%E4%1EXf%00%00%00%00IEND%AEB%60%82";
	var facebookImage = "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%3C%00%00%00%12%08%02%00%00%00%888*c%00%00%00%01sRGB%00%AE%CE%1C%E9%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%07tIME%07%DA%03%1F%109%1DA%0F%EA%E3%00%00%00%19tEXtComment%00Created%20with%20GIMPW%81%0E%17%00%00%01%EBIDATH%C7%D5W1h%DB%40%14%7D.N%20%A5p%A4%93%05%96E(%0Dd%B9%E1V%E1%A5dR)h%F4%A0M%5B%84%A7%22%BA%04O%EE%10D%E8%20%04%5D4%144h4%98xN%10Z%1AP%40%D9RJQ.%20O%A6%82N%E9%D2%C1%B1%EC%D8%10%D5I%13Wo%12%DC%FF%BA%C7%7B%EF%9Ft%95%9D%DD%0E%CA%86*%80%BA(-%D5%F3%FB%FA%D7%DA%FA%8BU1%BE%E2I%15%C0%F3%8D%F5%A5%DA%B2%EB%A5%5B%FE-%9E%A1%84%A8%DE%BD%BCU%DF%EC%EC%BD%D9%24%1B%00%3E~%3E%3E%3D%BF%FA%1FH%17(%9D3%BE%0FX%B3%E7h%26%7Br%A5%C7%8C%3F%7D%09O%BE%FE(%7C%97%ACO)%F2A%BF%9D%AE(%1E7%03%3B%CC%0Ak%C4%B7%EFL%86%D0%F5%AC%08%10%E8c%08%5CL%BA%E7h%F9%F3%E1%07%A50%D3%8D%1A%01%20%2B%D4%8Fb%9E%C6%D6%11%C0n%E4%97u%00%99%DF%ED%FBB%B3%A7O%8E%D74nwc%0E%C9t%9Ar%14%B4%87%D4V~ZF%80%A9%5D%89e%04%E1%A3%9E%1E%E1%20%E6%00%04j%3B%DAl%94C%D7S%DD%04%202%23%88%02%D5%F0T%C3S%DD%04%02m%B1i%FAm%85L%EC%CA%FC%AE%A7%1AA%08%C9%D4%A5%E5%94V%0D%2F%D7%FB%FD%C1%E0%FB%E5%A8%80u%1A%B7%8Dx%BC%B1%AD%10Y%A1%FE%60%A1F%A0%F6%3E%15%17%7B%A3%40u%93%B1-%00Z%FBZ%EB%E1%99%FE%1B%C8z%13n%10%02%3CJ%B8B%C54%E3%20%F35%0A%15%C7%A6%B3%99%9C%CC%E0r%98%01%F0%BB%7D%3F%7D%12%D2%80d%3A%92%99%AB%EE%26%60%8D%F9%08%9D%25%26%9B)%5B%00%3F%EA%5B5%CD%CC%95%9E80%87%CA%CEng%7B%FB%F5%DD%E38%17%8F%2C%1B%11%F2rU_%96%8B%8BoU%00%AF%1A%05%0C%EA%B5%5BFG%E7%23%AC%14%A5%FC%F7(%25%E9J%19%2F%01%7F%00%60%01%B7%01k%B6%83%26%00%00%00%00IEND%AEB%60%82";
	var tumblrImage = "data:image/gif;base64,R0lGODlhEAAQAOZuAD9cdyA3TT5bdkBdeCA3Tj1adTZSbCI6VEFeeUtphDhVb0VjfiM7UjdTbiE4T0dlgEhmgjxYc0lnglZfajRQazlVcENgezpWcbrAxzxZdDtYcyM6UT5adSQ7UkRhfDNPaUhlgUJgezlWcDdUbsDJ1FBpgSI5UCE5UL3EzlZtgz1ZdOHh5UFfepadpt/i6Ofo7cDI0is8TVljbjtXcj9JVi8/UTZSbbS6w3CHnTdTbThUbkVifTpXckdlgUlmgkdkgEpngzZTbSs6Sr/I0TpXcV9wgkZkf2V6j0JfejRJXjNMYzhPZUBbdDtYckFbc46hsuHm7D1YcWZ/lkRifUZkgCI6UUpogzVJXrvEzkhmgThUb4WZrOHl7EVifqu0v72/xba9xipDYENhfEZjf0lngyg0QkpohDRQajVRax82TUtphd/f4+vu8yg/WP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAG4ALAAAAAAQABAAAAfYgG5tg4SFhYIHZooJao2OjWEdbT4SZJZQbE6KZoxqkg8PPSBbbGxllZZAVgxtCwtjT1ylMjhSIFkQEKxiHh6lv2wwTEZUPxttCCxIQy6lGBgtNVM7XccAAANRKKVlSVdLIRYWVW0FBRwCJGwvZdgDAwgIJm1NGhERWCtrZecC/gAn2lQQceECmDVrJmg4UiJDBhUO2jQYoUOLF4QYixDhMSOigY82UtzA+IWGAgUVCLQ5QwGNSyUxJpQpIyRIjgYqD3z4cKZnz5Yu0Rwg4CaN0aNIAygN4CYQADs=";
	var voteValue = parseInt(voteResults.snapshotItem(0).innerHTML);
	var movieName = getMovieName();
	var imdbUrl = "http://imdb.com/title/tt"+getIMDBid();

	findPattern = "//td[@id='img_primary']/a/img";
	imageResults = document.evaluate( findPattern, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
	// make sure there's an image if we're going to share the image too
	if (imageResults.snapshotItem(0) != null) {
		var movieImage = imageResults.snapshotItem(0).src;
		shareFacebookUrl = 'http://www.facebook.com/connect/prompt_feed.php?attachment={"name"%3A"'+movieName+'"%2C"caption"%3A"{*actor*} '+movieName+' adl─▒ filme IMDb de 10 ├╝zerinden '+voteValue+' verdi."%2C"href"%3A"'+imdbUrl+'"%2C"media"%3A[{"type"%3A"image"%2C%0A     "src"%3A"'+escape(movieImage)+'"%2C"href"%3A"'+escape(imdbUrl)+'"}]}';
	}
	else {
		shareFacebookUrl = 'http://www.facebook.com/connect/prompt_feed.php?attachment={"name"%3A"'+movieName+'"%2C"caption"%3A"{*actor*} gave the film '+movieName+' a rating of '+voteValue+'/10 on IMDb."%2C"href"%3A"'+imdbUrl+'"}';
	}

	var shareTumblrUrl = 'http://www.tumblr.com/share?v=3&u=' +escape(imdbUrl)+ '&t=&s=I%20gave%20the%20film%20' +movieName+ '%20a%20rating%20of%20' +voteValue+ '/10%20on%20IMDb.';
	var shareTwitterUrl = 'http://twitter.com/home?status=gave the film '+movieName+' a rating of '+voteValue+'/10 on %23IMDb '+imdbUrl;

	addedDivFBLink = document.createElement('div');
	addedDivFBLink.innerHTML = '<span><strong>Share</strong> your vote:</span><a target="_blank" title="Share on Facebook" 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.setAttribute('id','GM_ShareVoteOnFacebook');

	findPattern = "//div[@class='social_networking']";
	placementResults = document.evaluate( findPattern, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
	placementResults.snapshotItem(0).parentNode.insertBefore(addedDivFBLink, placementResults.snapshotItem(0));

	if (shortenTwitterUrl) {
	
		var bitlyAPIFull = 'http://api.bit.ly/shorten?version=2.0.1&login='+bitlyLogin+'&apiKey='+bitlyKey+'&format=xml&longUrl=' + imdbUrl;
	
		GM_xmlhttpRequest({
			method: 'GET',
			url: bitlyAPIFull,
			headers:{
				"User-Agent":"Mozilla/5.0",
				"Accept":"text/xml"
			},    
			onload: function(results) {
				var parser = new DOMParser();
				var dom = parser.parseFromString(results.responseText, "application/xml");
				var shortLink = dom.getElementsByTagName('shortUrl')[0].textContent;
				var twitterLink = document.getElementById("GM_twitter_link");
				twitterLink.href = shareTwitterUrl.replace(imdbUrl, shortLink);
			}
		}); // end of ajax api request to bit.ly
	}
}

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

function getMovieName() {
	const $xpath = '//h1/text()';
	var $nodes = document.evaluate($xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
	return escape($nodes.singleNodeValue.data.replace(/[^\w -\xC0-\xFF]/g, ''));
}