Blur any website with a keyboard shortcut

you can Blur any website with a keyboard shortcut

当前为 2024-05-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Blur any website with a keyboard shortcut
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @license MIT
  6. // @description you can Blur any website with a keyboard shortcut
  7. // @author Rumman
  8. // @match *://*/*
  9. // @icon https://cdn.pixabay.com/photo/2015/06/24/02/12/the-blurred-819388_1280.jpg
  10. // @grant GM_addStyle
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. let isBlurred = false;
  17.  
  18. // Function to toggle blur effect
  19. function toggleBlur() {
  20. if (isBlurred) {
  21. GM_addStyle(`
  22. body {
  23. filter: none !important;
  24. pointer-events: auto !important;
  25. }
  26. `);
  27. isBlurred = false;
  28. } else {
  29. GM_addStyle(`
  30. body {
  31. filter: blur(8px) !important;
  32. pointer-events: none !important;
  33. }
  34. `);
  35. isBlurred = true;
  36. }
  37. }
  38.  
  39. // Event listener for keyboard shortcut (Ctrl+B)
  40. document.addEventListener('keydown', function(event) {
  41. if (event.ctrlKey && event.key === 'b') {
  42. toggleBlur();
  43. }
  44. });
  45. })();