// ==UserScript== // @name 一键默哀 // @namespace http://tampermonkey.net/ // @version 1.1 // @description Turn the entire page black and white on mobile devices // @author YourName // @match *://*/* // @grant none // @downloadURL https://update.greasyfork.icu/scripts/517962/%E4%B8%80%E9%94%AE%E9%BB%98%E5%93%80.user.js // @updateURL https://update.greasyfork.icu/scripts/517962/%E4%B8%80%E9%94%AE%E9%BB%98%E5%93%80.meta.js // ==/UserScript== (function () { 'use strict'; // Function to apply grayscale filter to the entire page function makePageGrayscale() { document.documentElement.style.filter = 'grayscale(100%)'; document.documentElement.style.transition = 'filter 0.3s'; } // Apply grayscale to the entire page immediately makePageGrayscale(); // Observe DOM changes to ensure the filter remains applied const observer = new MutationObserver(() => { makePageGrayscale(); }); observer.observe(document.body, { childList: true, subtree: true }); // Function to apply grayscale filter to video elements function makeVideosGrayscale(video) { video.style.filter = 'grayscale(100%)'; video.style.transition = 'filter 0.3s'; } // Observe DOM changes to detect new video elements const videoObserver = new MutationObserver(() => { const videos = document.querySelectorAll('video'); videos.forEach((video) => { if (!video.hasAttribute('data-grayscale-enabled')) { video.setAttribute('data-grayscale-enabled', 'true'); makeVideosGrayscale(video); } }); }); videoObserver.observe(document.body, { childList: true, subtree: true }); // Apply grayscale to existing videos on the page document.querySelectorAll('video').forEach((video) => { if (!video.hasAttribute('data-grayscale-enabled')) { video.setAttribute('data-grayscale-enabled', 'true'); makeVideosGrayscale(video); } }); })();