Greasy Fork 还支持 简体中文。

IMDb.com enable right click on images

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

目前為 2022-03-16 提交的版本,檢視 最新版本

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