Blur NSFW

NSFWをぼかしていい感じに見れるやつ

  1. // ==UserScript==
  2. // @name Blur NSFW
  3. // @namespace http://github.com/yuzulabo
  4. // @version 1.0.2
  5. // @description NSFWをぼかしていい感じに見れるやつ
  6. // @author nzws / ねじわさ
  7. // @match https://knzk.me/*
  8. // @match https://mastodon.cloud/*
  9. // @match https://friends.nico/*
  10. // @match https://mstdn.jp/*
  11. // @license MIT License
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. const mainElem = document.getElementById('mastodon');
  16. if (!mainElem) return;
  17.  
  18. const observer = new MutationObserver((mutations) => {
  19. mutations.forEach((mutation) => {
  20. let node = mutation.addedNodes;
  21. let i = 0;
  22. while (node[i]) {
  23. if (node[i].tagName) {
  24. let image = node[i].querySelector('.media-gallery');
  25. if (image) {
  26. if (image.children[1].className === 'media-spoiler') {
  27. image.children[1].click();
  28. let p = 1;
  29. while (image.children[p]) {
  30. image.children[p].className += ' image_blur';
  31. p++;
  32. }
  33. }
  34. }
  35. }
  36. i++;
  37. }
  38. });
  39. });
  40.  
  41. observer.observe(mainElem, { childList: true, subtree: true });
  42.  
  43. const style = document.createElement("style");
  44. style.innerHTML = ".image_blur {filter: blur(4px)}";
  45. document.querySelector("head").appendChild(style);
  46. })();