Greasy Fork镜像 支持简体中文。

osc动弹图片预览

再也不用打开新页面看图片啦

  1. // ==UserScript==
  2. // @name osc动弹图片预览
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.7
  5. // @description 再也不用打开新页面看图片啦
  6. // @author Hjj
  7. // @match https://www.oschina.net/tweets*
  8. // @match http://www.oschina.net/tweets*
  9. // @require http://cdn.staticfile.org/jquery/1.8.2/jquery.min.js
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Your code here...
  17. var _scale = 1;
  18. var previewBox = $('<div></div>');
  19. previewBox.css({
  20. 'position': 'fixed',
  21. 'top': '15px',
  22. 'left': '15px',
  23. 'display': 'none',
  24. 'transform-origin':'0 0',
  25. 'z-index': 99
  26. }).on('mousewheel',scale);
  27. $('body').append(previewBox);
  28. $('#mainScreen').on('click','.tweet-item img[data-small-img]',function(e){
  29. e.preventDefault();
  30. previewBox.css('transform','scale(1)');
  31. var bigSrc = $(e.target).attr('data-big-img');
  32. previewBox.empty().append(
  33. $('<img>').attr('src',bigSrc)
  34. .css({
  35. 'max-width': '100%',
  36. 'max-height': '100%'
  37. }).on('click',deleteSelf)
  38. ).show();
  39. return false;
  40. });
  41. function deleteSelf(e){
  42. $(e.target).parent().hide().end().remove();
  43. _scale = 1;
  44. }
  45. function scale(e){
  46. e.preventDefault();
  47. var delta = e.originalEvent.wheelDelta / 120;
  48. _scale += -delta/10;
  49. previewBox.css('transform','scale('+_scale+')');
  50. }
  51. })();

QingJ © 2025

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