Guest User

Untitled

a guest
Jan 9th, 2025
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Blur Images in posts
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Blur images in posts
  6. // @author Anonymous
  7. // @match https://boards.4chan.org/vg*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Helper function to check
  15. function hasReplyReference(postContainer) {
  16. const blockquote = postContainer.querySelector('.postMessage');
  17. if (blockquote) {
  18. return blockquote.textContent.includes('>>'); // Check for reply references
  19. }
  20. return false;
  21. }
  22.  
  23. // Function to blur images
  24. function blurReplyImages() {
  25. const posts = document.querySelectorAll('.postContainer');
  26. posts.forEach(post => {
  27. // Check if the post contains reply references
  28. if (hasReplyReference(post)) {
  29. const images = post.querySelectorAll('.fileThumb img');
  30. images.forEach(img => {
  31. img.style.filter = 'blur(40px)';
  32. img.style.transition = 'filter 0.1s';
  33.  
  34. // Unblur on hover
  35. img.addEventListener('mouseenter', () => {
  36. img.style.filter = 'none';
  37. });
  38.  
  39. img.addEventListener('mouseleave', () => {
  40. img.style.filter = 'blur(40px)';
  41. });
  42. });
  43. }
  44. });
  45. }
  46.  
  47. // Observe for dynamic content loading (e.g., infinite scrolling)
  48. const observer = new MutationObserver(() => {
  49. blurReplyImages();
  50. });
  51.  
  52. observer.observe(document.body, { childList: true, subtree: true });
  53.  
  54. // Initial run
  55. blurReplyImages();
  56. })();
  57.  
  58.  
Tags: Filter
Add Comment
Please, Sign In to add comment