Block lemmy instances

Remove posts and comments from specified instances.

当前为 2023-06-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Block lemmy instances
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4.0
  5. // @description Remove posts and comments from specified instances.
  6. // @author RyanHx
  7. // @match https://vlemmy.net/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. const target = document.getElementById("app");
  15. const config = { attributes: false, childList: true, subtree: true };
  16. const callback = (mutationList, observer) => {
  17. const blockedInstances = ["example.ml","anotherexample.world"];
  18. for (const instance of blockedInstances) {
  19. let link = document.querySelector(`div.post-listing a[title$="${instance}"], li.comment a[title$="${instance}"]`);
  20. while (link) {
  21. const post = link.closest("div.post-listing, li.comment");
  22. const divider = post.nextElementSibling;
  23. console.log(`Removing ${post}`);
  24. post.remove();
  25. if (divider?.nodeName === "HR") {
  26. divider.remove();
  27. }
  28. link = document.querySelector(`div.post-listing a[title$="${instance}"], li.comment a[title$="${instance}"]`);
  29. }
  30. }
  31. }
  32. const observer = new MutationObserver(callback);
  33. observer.observe(target, config);
  34. callback(null,null);
  35. })();