Blur YouTube Videos with Shortcut

Apply a 100px blur effect to YouTube videos with Alt+Y

目前为 2025-01-07 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Blur YouTube Videos with Shortcut
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Apply a 100px blur effect to YouTube videos with Alt+Y
  6. // @author Drewby123
  7. // @match *://www.youtube.com/*
  8. // @license MIT
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. let isBlurred = false; // Track the blur state
  16.  
  17. // Function to toggle the blur effect
  18. function toggleBlur() {
  19. const videos = document.querySelectorAll('video');
  20. isBlurred = !isBlurred;
  21. const blurValue = isBlurred ? 'blur(100px)' : 'none'; // Toggle blur
  22. videos.forEach(video => {
  23. video.style.filter = blurValue;
  24. video.style.transition = 'filter 0.5s'; // Smooth transition
  25. });
  26. }
  27.  
  28. // Event listener for Alt+Y
  29. document.addEventListener('keydown', event => {
  30. if (event.altKey && event.key.toLowerCase() === 'y') {
  31. toggleBlur();
  32. }
  33. });
  34.  
  35. // Apply blur to dynamically loaded videos
  36. const observer = new MutationObserver(() => {
  37. if (isBlurred) {
  38. const videos = document.querySelectorAll('video');
  39. videos.forEach(video => {
  40. video.style.filter = 'blur(100px)';
  41. video.style.transition = 'filter 0.5s';
  42. });
  43. }
  44. });
  45.  
  46. observer.observe(document.body, {
  47. childList: true,
  48. subtree: true
  49. });
  50. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址