Greasy Fork is available in English.

iMDB Large Images

Large iMDB images when you hover over them.

  1. // ==UserScript==
  2. // @name iMDB Large Images
  3. // @version 1.0.14
  4. // @description Large iMDB images when you hover over them.
  5. // @namespace https://greasyfork.org/en/scripts/11249-imdb-large-images
  6. // @homepage https://greasyfork.org/en/scripts/11249-imdb-large-images
  7. // @match http://imdb.com/*
  8. // @match https://imdb.com/*
  9. // @match http://*.imdb.com/*
  10. // @match https://*.imdb.com/*
  11. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAQCAYAAAB3AH1ZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABgdJREFUeNokVVtvXFcZXXufc+aWudszY8eO7ZjGaRIFCvSWcGtUISFKVbW0D7xFfeAFiR8ASFxUCREJ+oKE0pcqFFEpKiCoEGnVi0JV6ENERIRpQ5P4Eo89Hntsz/1c9oV1jmd0dM7e++zvrG9961tb9LZ/i2xmDmbwzg+VXjk7Cgu+NcKRiISwgIW0xgoYA2GEssI6sNqxEL6AdVwIKwGjjXKNNVIqaaQWBmklYa2BRgBAaDCGq6wbuX5KVs6/ns2dveqPtuFGZhJGffwVJ7r6Ume7iZRTZswBtAngmAoURjCICCANazJQdsiAiiGzcAhGC8V3oxgdwWYQGQkJwbkebJSCcTwoAiJYqCjOaIAptL7a319/c+TWx64J3/oBgvd/tLc1QF4uoXaiChQbgNYwrTXImRl+0AHCCKP1JnIzXMtmgaHGYPMO8o1ZLldIwgET5baDHXQ3NlFeOg/p1XFwbxudwToymQy8dB2tlSb21u5U07X+h7L4zZ+Kzu3TLXTbDTiLqC5k8K/lPC6/OsT8dAHPPFPA1avb2OlozM0BL35nFq/9bhcrGwHKkxrPPXsK7/xtHRutEZkJiCuN576Vw0MPZvGL3/Sw0gzxvedLePxcGyurI/z3ZgcTU1Wk0xKpaBOp/Jk7ro3q9yGdRrZImo5I/Oe2wiuvXkclX8O580/h5y9/QFojeJksHvnCY3jp5Ws4GH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YK97fuo16fRI7l2WgfwK1c+L3Yar6Nzsq1746bVy7PLRyH7w9Yez/WIeufQXyexSKJvcLqeJK1451V5mHEOfawTE5IipKCNE6GK/F8wAOMb2kLN95rPaRc3l0f92ichaknLs4sXrgiNu69Bk9ZrP7vjT8ovfogazxme3Bb7FDwBKRRRluH32S/Sm0OP0ypS5+vGemY+LCLz+Kk8SxHbO3YqmIzi70g4h66v6Hjyf397axX/vzy0kPPvxAM2vi/AAMASJUzNk9kVxUAAAAASUVORK5CYII=
  12. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. this.$ = this.jQuery = jQuery.noConflict(true);
  17.  
  18. /*!
  19. * hoverIntent v1.8.0 // 2014.06.29 // jQuery v1.9.1+
  20. * http://cherne.net/brian/resources/jquery.hoverIntent.html
  21. *
  22. * You may use hoverIntent under the terms of the MIT license. Basically that
  23. * means you are free to use hoverIntent as long as this header is left intact.
  24. * Copyright 2007, 2014 Brian Cherne
  25. */
  26. (function($){$.fn.hoverIntent=function(handlerIn,handlerOut,selector){var cfg={interval:100,sensitivity:6,timeout:0};if(typeof handlerIn==="object"){cfg=$.extend(cfg,handlerIn)}else{if($.isFunction(handlerOut)){cfg=$.extend(cfg,{over:handlerIn,out:handlerOut,selector:selector})}else{cfg=$.extend(cfg,{over:handlerIn,out:handlerIn,selector:handlerOut})}}var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if(Math.sqrt((pX-cX)*(pX-cX)+(pY-cY)*(pY-cY))<cfg.sensitivity){$(ob).off("mousemove.hoverIntent",track);ob.hoverIntent_s=true;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=false;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=$.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type==="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).on("mousemove.hoverIntent",track);if(!ob.hoverIntent_s){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).off("mousemove.hoverIntent",track);if(ob.hoverIntent_s){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.on({"mouseenter.hoverIntent":handleHover,"mouseleave.hoverIntent":handleHover},cfg.selector)}})(jQuery);
  27.  
  28. $(document).ready(function() {
  29.  
  30. var cssCode = `
  31. #largeImagePopover {
  32. position: absolute;
  33. box-shadow: 0 0 15px #000;
  34. cursor: pointer;
  35. z-index: 1000;
  36. }
  37. #largeImagePopover a.largeImageOriginal {
  38. font-family: sans-serif;
  39. font-size: 10px;
  40. background: rgba(0, 0, 0, 0.5);
  41. color: white;
  42. position: absolute;
  43. bottom: 2px;
  44. right: 2px;
  45. padding: 2px;
  46. z-index: 1001;
  47. }
  48. `;
  49.  
  50. var styleElement = document.createElement("style");
  51. styleElement.type = "text/css";
  52. if (styleElement.styleSheet) {
  53. styleElement.styleSheet.cssText = cssCode;
  54. } else {
  55. styleElement.appendChild(document.createTextNode(cssCode));
  56. }
  57. document.getElementsByTagName("head")[0].appendChild(styleElement);
  58.  
  59. var hoverInFunction = function (e) {
  60.  
  61. var hoveredImage = this.src ? this : $(this).parent().find('img').get(0) || $(this).parent().parent().find('img').get(0);
  62.  
  63. if(!hoveredImage) {
  64. console.log("Image Not Found");
  65. return;
  66. }
  67.  
  68. hoveredImage.style.cursor = 'progress';
  69.  
  70. $('div#largeImagePopover, div.largeImagePopover').remove();
  71. $("body").css("overflow", "auto");
  72.  
  73. // setup the large image
  74. var popImage = document.createElement("img");
  75. var src = hoveredImage.src;
  76.  
  77. src = src.replace(/_V1\.?.*?_\./g,"_V1_.");
  78. var srcorig = src;
  79. src = src.replace(/_V1_?\.jpg/,"_V1_SY"+window.innerHeight+"_.jpg");
  80.  
  81. popImage.src = src
  82. popImage.alt = hoveredImage.alt;
  83. popImage.border = 0;
  84.  
  85. // setup the image link
  86. var popLink = document.createElement("a");
  87. popLink.href = this.href ? this.href
  88. : $(this).parent().attr('href')
  89. || $(this).parent().find("a").attr('href')
  90. || $(this).parent().parent().attr('href')
  91. || $(this).parent().parent().find("a").attr('href')
  92. || $(this).parent().parent().parent().attr('href')
  93. || $(this).parent().parent().parent().find("a").attr('href')
  94. || $(this).parent().parent().parent().parent().attr('href')
  95. || $(this).parent().parent().parent().parent().find("a").attr('href');
  96. popLink.appendChild(popImage);
  97.  
  98. var popLinkOriginal = document.createElement("a");
  99. popLinkOriginal.className = 'largeImageOriginal';
  100. popLinkOriginal.href = srcorig;
  101. popLinkOriginal.target = "_blank";
  102. popLinkOriginal.innerHTML = "[ ORIGNAL ]";
  103.  
  104. // setup the image div
  105. var popDiv = document.createElement("div");
  106. popDiv.id = 'largeImagePopover';
  107. popDiv.className = 'largeImagePopover';
  108. popDiv.appendChild(popLink);
  109. popDiv.appendChild(popLinkOriginal);
  110. $(popDiv).hide();
  111.  
  112. // attach events to new image
  113. $(popDiv).mouseleave( function() {
  114. $(popDiv).remove();
  115. });
  116. $(popImage).css('cursor','crosshair');
  117.  
  118. $(popImage).load( function() {
  119. // these assignments may differ per browser
  120. var pageXOffset = window.pageXOffset;
  121. var pageYOffset = window.pageYOffset;
  122. var innerWidth = window.innerWidth;
  123. var innerHeight = window.innerHeight;
  124. var mouseX = e.pageX;
  125. var mouseY = e.pageY;
  126.  
  127. // shrink image if wider than screen
  128. if(popImage.width > innerWidth-17) {
  129. var tmpW = popImage.width;
  130. popImage.width = Math.min(popImage.width,innerWidth-17);
  131. popImage.height = (popImage.width/tmpW) * popImage.height;
  132. }
  133. if(popImage.height > innerHeight) {
  134. var tmpH = popImage.height;
  135. popImage.height = Math.min(popImage.height,innerHeight);
  136. popImage.width = (popImage.height/tmpH) * popImage.width;
  137. }
  138.  
  139. // center image on mouse cursor
  140. var x = mouseX - parseInt(popImage.width/2);
  141. var y = mouseY - parseInt(popImage.height/2);
  142.  
  143. // move image down and right if off screen to the left or top
  144. x = Math.max(x,pageXOffset);
  145. y = Math.max(y,pageYOffset);
  146.  
  147. // move image up or left if off screen to the right or bottom
  148. x = Math.min(x, pageXOffset + innerWidth - 17 - popImage.width)
  149. y = Math.min(y, pageYOffset + innerHeight - popImage.height);
  150.  
  151. // move image down and right if off screen to the left or top
  152. x = Math.max(x,pageXOffset);
  153. y = Math.max(y,pageYOffset);
  154.  
  155. $(popImage.parentNode.parentNode).css('left',x);
  156. $(popImage.parentNode.parentNode).css('top',y);
  157. $(popImage.parentNode.parentNode).show();
  158.  
  159. hoveredImage.style.cursor = 'crosshair'
  160. });
  161.  
  162. $('body').append($(popDiv));
  163. };
  164.  
  165. $(document).keyup(function(e) {
  166. if (e.keyCode == 27) {
  167. $('div#largeImagePopover, div.largeImagePopover').remove();
  168. }
  169. });
  170.  
  171. function checkImages() {
  172. $("img[src*='_V1']").not("img[src*='_ZA']").not(".imageDone").each(function() {
  173. $(this).addClass('imageDone').css('cursor','crosshair').hoverIntent( hoverInFunction, function(){} );
  174. });
  175. $("a.ipc-lockup-overlay").not(".imageDone").each(function() {
  176. $(this).addClass('imageDone').css('cursor','crosshair').hoverIntent( hoverInFunction, function(){} );
  177. });
  178.  
  179. window.setTimeout(checkImages, 1000);
  180. }
  181.  
  182. checkImages();
  183.  
  184. });