NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name imdb link in speed.cd title // @namespace pootz // @description insert imdb link in the title of the details page // @include http*://*speed.cd/details.php?id=* // @include http*://*speed.cd/t/* // @version 1.9 // @history 1.9 - fix after imdb change, imdb icon of movies without rate are no longer shown // @history 1.8 - fix movies not yet released // @history 1.7 - fix a bug where a movie not yet rated, would not insert the imdb icon button // @history 1.6 - fix to work after page changes // @history 1.5 - when the imdb link is found, it show the rates instead of the icon // @history 1.4 - fix http bug, where the description link not preceeded by http would fail to open // @history 1.3 - add imdb as button so it still appears when movie title is longer // @history 1.2 - find for the title and until year, and retrieve imdb link's search results if found // @history 1.1 - regex range updated // @require https://code.jquery.com/jquery-2.1.1.min.js // @updateURL https://openuserjs.org/meta/pootz/imdb_link_in_speed.cd_title.meta.js // @downloadURL https://openuserjs.org/install/pootz/imdb_link_in_speed.cd_title.user.js // @grant GM_addStyle // @grant GM_xmlhttpRequest // ==/UserScript== imdbIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAVCAYAAAAAY20CAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAhsSURBVFhHZVdbbBxXGf5mdmfvvsR2XHtdJ62TUJzipCEJLrQSKoWUkKoCFEBCiuAhPIBEkcobQgiEiFSEqARCiIeCKA9UiBYUQZK+UCVpqUQqXCdpkiaKY6fx2o6zvu/O7uxc+P5/ztob8612zjn/Oee/n3/OWPPz9yIQnYUbcKe/ClgOfA8IQyUjYiM9y7RRKAOhxwSl8Q+hE9oXuk7wIWube9jG8/K02GdLOTFNHnEThZzjeotz4bpgIOmQHnroG34VlXBE168bkA9OwK/+m4pncXfGQ66Q4GIy4GyThzwio03TsPgh9PWuDuKxPERRw0OUVeOVQzynSsoeocVz6gvOWRyEnLBswF0NsbWYhmW5yLaNwu75iayCVVv8U+S7byGoXUY6k0JpqkHlLRQ6k/Ab3E5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E0kmrUPENamZgKrtfg158oldBUEev8hg+Lt9ZIrtM8qiFTp8Y1DSZDV6+D9o4k5mc9eHUPS3PjsJZmTkflqT+gsnSFm7N4YCBN3hbKcx7sBFlQoECuEdrlQ14ycnONq1ecj7JH011SkI18TYnhWmGUwL+cMekYQ0Rh+RrTLy8ZMy+0Smn6N/fxxco2l7P5ReZg4qrLzxEXqUw3Bh89vvFJWS39HMulM7Q+j+L2lF6ahIeRa5QzcnVH3NGu0NVASjJzzTXrrTCRNTbb5jIhNeel5V+/+rhWfxzTTbEB/MSdm27wml/l1+JOPPTJl7kB+B93xOBaC/ZrgwAAAABJRU5ErkJggg=="; var movieSearch = /xvid|264|[^a-z0-9](20[0-3][0-9]|19[1-9][0-9])/i; var untilYear = /[\w\d '-]+[ |\[|\(](20[0-3][0-9]|19[0-9][0-9])/; var titleID = $("#boxTitle"); var torrentTitle = titleID.prop("title"); var searchImdb = /(http:\/\/www.imdb.com\/title\/tt\d{7})|(http:\/\/imdb.com\/title\/tt\d{7})|(www.imdb.com\/title\/tt\d{7})|(http:\/\/akas.imdb.com\/title\/tt\d{7})/i; var details = $(".infoBody").html(); var torrentOptions = $('.tOpt'); if ( searchImdb.test(details) ) { var imdb = details.match(searchImdb)[0]; if (imdb.indexOf("http") == -1) { imdb = "http://" + imdb; } GM_xmlhttpRequest ( { method: "GET", url: imdb, onload: imdbRate }); } else if ( movieSearch.test(torrentTitle) ) { if ( untilYear.test(torrentTitle) ) { var imdbSearch = "http://www.imdb.com/find?q=" + encodedTitle(true) + "&s=tt&exact=true"; GM_xmlhttpRequest ( { method: "GET", url: imdbSearch, onload: imdbResults }); } } function insertImdbButton(imdb) { if (imdb != "undefined" || imdb !== null) { torrentOptions.append('<span> </span><label class="uiButton"><a href="' + imdb + '" target="_blank"><img src="' + imdbIcon + '"></img></a></label>'); } } function insertRate(imdb, rates) { if (rates != "undefined" || rates !== null) { torrentOptions.append('<span> </span><label class="uiButton"><a href="' + imdb + '" target="_blank"><font color="blue" size="4">' + rates + '</font></a></label>'); } else { insertImdbButton(imdb); } } function imdbRate(object) { var resp = $(object.responseText); //var isRated = resp.find('div.ratings_wrapper')[0].textContent.trim(); var rate = resp.find('span[itemprop="ratingValue"]'); var count = resp.find('span[itemprop="ratingCount"]'); var rates = rate[0].textContent + " (" + count[0].textContent + ")"; insertRate(imdb, rates); } function imdbResults(object) { var respDoc = $(object.responseText); var linkTitleYear = respDoc.find('.result_text'); var imdb = "http://www.imdb.com"; var foundIt = false; var year = encodedTitle(false); for (var i = 0; i < linkTitleYear.length; i++) { var searchTitle = linkTitleYear[i].textContent; var iLink = linkTitleYear[i].getElementsByTagName("a")[0].getAttribute("href"); if (searchTitle.indexOf( year ) != -1) { foundIt = true; var searchLink = iLink.slice( iLink, iLink.indexOf("/?") ); imdb = imdb + searchLink; insertImdbButton(imdb); break; } } if (!foundIt) { imdb = imdbSearch; insertImdbButton(imdb); } } function encodedTitle( boolean ) { var year = /20[0-3][0-9]|19[0-9][0-9]/; var grabYear = torrentTitle.match(year)[0]; var grabTitle = torrentTitle.match(untilYear)[0].toLowerCase(); grabTitle = grabTitle.slice( 0, -5 ); grabTitle = grabTitle.replace(/-|\(|\[|'|/g,""); grabTitle = grabTitle.replace(/ | /g, " "); grabTitle = grabTitle.replace(/ VS | vs /g," vs. "); if (grabTitle.charAt(0) == " ") { grabTitle = grabTitle.slice(1); } if (grabTitle.charAt(grabTitle.length - 1) == " ") { grabTitle = grabTitle.slice(0,-1); } var grabEncodedTitle = grabTitle.replace(/&/g,"%26"); grabEncodedTitle = grabEncodedTitle.replace(/\?/g,"%3F"); grabEncodedTitle = grabEncodedTitle.replace(/=/g,"%3D"); grabEncodedTitle = grabEncodedTitle.replace(/ /g,"+"); if (boolean) return grabEncodedTitle; else return grabYear; }