Nitter - Image Hover

Hover over images to show the fullsize image beside the mouse cursor.

  1. // ==UserScript==
  2. // @name Nitter - Image Hover
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Hover over images to show the fullsize image beside the mouse cursor.
  6. // @author Gondola#7671
  7. // @match https://nitter.net/*
  8. // @require http://code.jquery.com/jquery-3.4.1.min.js
  9. // @icon https://www.google.com/s2/favicons?domain=nitter.net
  10. // @compatible firefox
  11. // @compatible chrome
  12. // @run-at document-idle
  13. // ==/UserScript==
  14.  
  15. $(document).ready(function(){
  16.  
  17. /*---START Image Hover---*/
  18. var mouse_offset_x = 16;
  19. var mouse_offset_y = 16;
  20. var mouse_side = false;
  21. var currentMousePos = { x: -1, y: -1 };
  22.  
  23.  
  24. $("body").append("<img id='img_hover_container' style='float:left; position:absolute; max-width:200px; overflow:hidden; z-index:9999;' src=''>")
  25.  
  26.  
  27. $(".still-image").mouseenter(function()
  28. {
  29. $("#img_hover_container").attr("src","https://nitter.net" + $(this).attr('href'))
  30. $("#img_hover_container").css("max-height",$(window).height())
  31. })
  32.  
  33.  
  34. $(".still-image").mouseleave(function()
  35. {
  36. $("#img_hover_container").attr("src","")
  37. })
  38.  
  39.  
  40. //Update Mouse Position
  41. $(document).mousemove(function(event)
  42. {
  43. currentMousePos.x = event.pageX;
  44. currentMousePos.y = event.pageY;
  45. update_pos();
  46. });
  47.  
  48.  
  49. function update_pos()
  50. {
  51. //Mouse Horizontal
  52. if(currentMousePos.x > ($(window).width()/2))
  53. {
  54. mouse_side = true;
  55. mouse_offset_x = -$("#img_hover_container").width() - 16;
  56. $("#img_hover_container").css("max-width", currentMousePos.x - 16)
  57. }
  58. else
  59. {
  60. mouse_side = false;
  61. mouse_offset_x = 16;
  62. $("#img_hover_container").css("max-width", $(window).width()-currentMousePos.x)
  63. }
  64.  
  65. //Mouse Vertical
  66. if(currentMousePos.y > ($(window).height() - $("#img_hover_container").height()))
  67. {
  68. mouse_offset_y = ($(window).height() - $("#img_hover_container").height()) + $(document).scrollTop();
  69. }
  70. else
  71. {
  72. mouse_offset_y = currentMousePos.y + 16;
  73. }
  74.  
  75. $("#img_hover_container").offset({
  76. top: mouse_offset_y,
  77. left: currentMousePos.x + mouse_offset_x
  78. });
  79. }
  80.  
  81.  
  82. //Update image position periodically
  83. var intervalID = setInterval(function(){update_pos();}, 100);
  84.  
  85. $("#img_hover_container").css("max-height", $(window).height())
  86. /*---END Image Hover---*/
  87.  
  88. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址