IMDb.com enable right click on images

Enable right click on images in the IMDb.com media viewer

当前为 2022-12-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IMDb.com enable right click on images
  3. // @namespace https://openuserjs.org/users/cuzi
  4. // @license GPL-3.0-or-later
  5. // @copyright 2020, cuzi (https://openuserjs.org/users/cuzi)
  6. // @version 1.1.1
  7. // @description Enable right click on images in the IMDb.com media viewer
  8. // @author cuzi
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=imdb.com
  10. // @match https://www.imdb.com/*
  11. // @grant GM.openInTab
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. 'use strict'
  16.  
  17. function highestQuality (ev) {
  18. if (!ev || ev.button !== 1) {
  19. return
  20. }
  21. const src = this.currentSrc.replace(/\.[^/.]*_[^/.]*\.+([^./]*)$/, '.$1')
  22. GM.openInTab(src)
  23. }
  24.  
  25. window.setInterval(function () {
  26. /* old before 2022-03-16 */
  27. document.querySelectorAll('div[class*="PortraitContainer"],div[class*="LandscapeContainer"]').forEach(function (div) {
  28. div.style.zIndex = 2
  29. })
  30.  
  31. /* new 2022-03-16 */
  32. document.querySelectorAll('.media-viewer div>img[srcset][data-image-id]').forEach(function (img) {
  33. img.removeEventListener('mouseup', highestQuality)
  34. if (img.clientWidth) {
  35. // Downsize the image container so it won't overlap the arrows for navigation
  36. img.parentNode.style.width = img.clientWidth + 'px'
  37. // Bring image container to the front
  38. img.parentNode.style.zIndex = 2
  39. // Try to load highest quality src on wheel click
  40. img.addEventListener('mouseup', highestQuality)
  41. img.title = 'Mouse wheel click to open highest quality\nRight click to open context menu'
  42. } else {
  43. // Reset if image size is not loaded yet
  44. img.parentNode.style.width = ''
  45. img.parentNode.style.zIndex = ''
  46. }
  47. })
  48. }, 700)
  49. })()