Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Blur Images in posts
- // @namespace http://tampermonkey.net/
- // @version 1.0
- // @description Blur images in posts
- // @author Anonymous
- // @match https://boards.4chan.org/vg*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // Helper function to check
- function hasReplyReference(postContainer) {
- const blockquote = postContainer.querySelector('.postMessage');
- if (blockquote) {
- return blockquote.textContent.includes('>>'); // Check for reply references
- }
- return false;
- }
- // Function to blur images
- function blurReplyImages() {
- const posts = document.querySelectorAll('.postContainer');
- posts.forEach(post => {
- // Check if the post contains reply references
- if (hasReplyReference(post)) {
- const images = post.querySelectorAll('.fileThumb img');
- images.forEach(img => {
- img.style.filter = 'blur(40px)';
- img.style.transition = 'filter 0.1s';
- // Unblur on hover
- img.addEventListener('mouseenter', () => {
- img.style.filter = 'none';
- });
- img.addEventListener('mouseleave', () => {
- img.style.filter = 'blur(40px)';
- });
- });
- }
- });
- }
- // Observe for dynamic content loading (e.g., infinite scrolling)
- const observer = new MutationObserver(() => {
- blurReplyImages();
- });
- observer.observe(document.body, { childList: true, subtree: true });
- // Initial run
- blurReplyImages();
- })();
Add Comment
Please, Sign In to add comment