Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Blur Media
- // @namespace http://tampermonkey.net/
- // @version 1.0
- // @description Blur images and videos until clicked, with temporary unblur on hover
- // @author You
- // @match *://kiwifarms.st/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // Style for blurring media
- const blurStyle = `
- .blurred {
- filter: blur(15px);
- transition: filter 0.3s ease;
- }
- .blurred:hover {
- filter: none;
- }
- `;
- // Create and add the style to the document head
- const styleSheet = document.createElement('style');
- styleSheet.type = 'text/css';
- styleSheet.innerText = blurStyle;
- document.head.appendChild(styleSheet);
- // Function to blur all media elements
- function blurMedia() {
- const mediaElements = document.querySelectorAll('img, video');
- mediaElements.forEach(media => {
- if (!media.classList.contains('blurred')) {
- media.classList.add('blurred');
- media.addEventListener('click', () => {
- media.classList.remove('blurred');
- });
- }
- });
- }
- // Run the blurMedia function initially
- blurMedia();
- // Observe DOM changes to handle dynamically added media
- const observer = new MutationObserver(() => {
- blurMedia();
- });
- // Start observing the document body for changes
- observer.observe(document.body, { childList: true, subtree: true });
- })();
Advertisement
Add Comment
Please, Sign In to add comment