Telegram-Web Image Display Switch

none

  1. // ==UserScript==
  2. // @name Telegram-Web Image Display Switch
  3. // @namespace zunsthy@gmail.com
  4. // @description none
  5. // @include https://web.telegram.org/*
  6. // @match https://web.telegram.org/*
  7. // @version 1.0.0
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11.  
  12. const createStyleElement = (css) => {
  13. const styleElement = document.createElement('style');
  14. styleElement.type = 'text/css';
  15. if (styleElement.styleSheet) {
  16. styleElement.styleSheet.cssText = css;
  17. } else {
  18. styleElement.textContent = css;
  19. }
  20.  
  21. return styleElement;
  22. };
  23.  
  24. (() => {
  25. const container = document.querySelector('head');
  26.  
  27. const css = `
  28. div[ng-switch-when="sticker"],
  29. a.im_message_photo_thumb,
  30. a.im_message_video_thumb,
  31. div.img_gif_image_wrap,
  32. div.im_message_webpage_wrap {
  33. position: relative;
  34. }
  35. div[ng-switch-when="sticker"]::after {
  36. content: "【贴图已隐藏】";
  37. }
  38. a.im_message_photo_thumb::after {
  39. content: "【图片已隐藏】";
  40. }
  41. a.im_message_video_thumb::after {
  42. content: "【视频已隐藏】";
  43. }
  44. div.img_gif_image_wrap::after {
  45. content: "【GIF已隐藏】";
  46. }
  47. div.im_message_webpage_wrap::after {
  48. content: "【链接预览已隐藏】";
  49. }
  50. div[ng-switch-when="sticker"]::after,
  51. a.im_message_photo_thumb::after,
  52. a.im_message_video_thumb::after,
  53. div.img_gif_image_wrap::after,
  54. div.im_message_webpage_wrap::after {
  55. display: block;
  56. position: absolute;
  57. top: 0;
  58. right: 0;
  59. bottom: 0;
  60. left: 0;
  61. color: white;
  62. background-color: rgba(0, 0, 0, .9);
  63. }
  64. `;
  65. const style = createStyleElement(css);
  66.  
  67. container.appendChild(style);
  68. window.CoverImage = () => {
  69. container.appendChild(style);
  70. };
  71. window.DisplayImage = () => {
  72. container.removeChild(style);
  73. };
  74. })();

QingJ © 2025

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