Guest User

Untitled

a guest
Jan 11th, 2025
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. // ==UserScript==
  2. // @name /bag/ filter 2nd
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.5
  5. // @description Hiding
  6. // @author Anonymous
  7. // @match https://boards.4chan.org/vg*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Check for a thread.
  15. if (!/^bag\/|\/bag\/|Blue Archive|BIue Archive/.test(document?.querySelector('.postInfo.desktop .subject')?.textContent?.trim() ?? '')) return;
  16.  
  17. // Helper function
  18. function hasReplyReference(postContainer) {
  19. const blockquote = postContainer.querySelector('.postMessage');
  20. return blockquote && blockquote.textContent.includes('>>');
  21. }
  22.  
  23. // Add CSS
  24. const style = document.createElement('style');
  25. style.textContent = `
  26. .fileThumb img.hidden-image {
  27. visibility: hidden;
  28. opacity: 0;
  29. width: 50px;
  30. height: 50px;
  31. transition: opacity 0.3s ease, visibility 0.3s ease, width 0.3s ease, height 0.3s ease;
  32. }
  33.  
  34. .fileThumb:hover img.hidden-image {
  35. visibility: visible;
  36. opacity: 1;
  37. width: auto; /* Return to original width */
  38. height: auto; /* Return to original height */
  39. }
  40. `;
  41. document.head.appendChild(style);
  42.  
  43. // Function to apply
  44. function hideAndResizeReplyImages() {
  45. const posts = document.querySelectorAll('.postContainer');
  46. posts.forEach(post => {
  47. // Check
  48. if (hasReplyReference(post)) {
  49. const thumbnails = post.querySelectorAll('.fileThumb img');
  50. thumbnails.forEach(thumb => {
  51. // Apply class
  52. if (!thumb.classList.contains('hidden-image')) {
  53. thumb.classList.add('hidden-image');
  54.  
  55. // Explicitly set width and height
  56. thumb.style.width = '50px';
  57. thumb.style.height = '50px';
  58.  
  59. // Restore
  60. thumb.addEventListener('mouseenter', () => {
  61. thumb.style.width = '';
  62. thumb.style.height = '';
  63. });
  64.  
  65. // Reapply
  66. thumb.addEventListener('mouseleave', () => {
  67. thumb.style.width = '50px';
  68. thumb.style.height = '50px';
  69. });
  70. }
  71. });
  72. }
  73. });
  74. }
  75.  
  76. // Observe for dynamic content loading (e.g., infinite scrolling)
  77. const observer = new MutationObserver(() => {
  78. hideAndResizeReplyImages();
  79. });
  80.  
  81. observer.observe(document.body, { childList: true, subtree: true });
  82.  
  83. // Initial run
  84. hideAndResizeReplyImages();
  85. })();
Advertisement
Add Comment
Please, Sign In to add comment