TG WebA User Blocker

Block user in Telegram group

  1. // ==UserScript==
  2. // @name TG WebA User Blocker
  3. // @namespace https://github.com/scientificworld
  4. // @version 2024-07-29
  5. // @description Block user in Telegram group
  6. // @author scientificworld
  7. // @license Unlicense
  8. // @match https://web.telegram.org/a/
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=telegram.org
  10. // @require https://cdn.jsdelivr.net/gh/CoeJoder/waitForKeyElements.js@a03933c5e42343b434c7800eb2777575342d8287/waitForKeyElements.js
  11. // @require https://update.gf.qytechs.cn/scripts/455875/1123973/AkiLib.js
  12. // @grant GM_setValue
  13. // @grant GM_getValue
  14. // @grant GM_registerMenuCommand
  15. // ==/UserScript==
  16.  
  17. let blocked = aki.createNormalMenu("Blocked user IDs (comma-delimited)");
  18.  
  19. waitForKeyElements("#MiddleColumn", () => {
  20. const observer = new MutationObserver(mutations => {
  21. mutations.forEach(mutation => {
  22. if (mutation.addedNodes) {
  23. mutation.addedNodes.forEach(node => {
  24. // if (["Message", "MessageList"].some(c => node.classList.contains(c)))
  25. if (node.classList) {
  26. let elements;
  27. if (node.classList.contains("Message")) {
  28. elements = [node];
  29. } else if (node.classList.contains("MessageList")) {
  30. if (node.classList.contains("no-avatars")) {
  31. return;
  32. }
  33. elements = node.querySelectorAll(".Message");
  34. }
  35. if (elements) {
  36. elements.forEach(element => {
  37. if (!element.classList.contains("own")) {
  38. let peerId, sibling = element;
  39. while (!peerId && sibling) {
  40. try {
  41. peerId = sibling.querySelector(".Avatar.size-small").dataset.peerId;
  42. } catch (error) {
  43. sibling = sibling.nextElementSibling;
  44. }
  45. }
  46. if (aki.getMenuValue(blocked).split(",").includes(peerId)) {
  47. element.style.display = "none";
  48. }
  49. element.dataset.peerId = peerId;
  50. // console.log(element);
  51. }
  52. });
  53. }
  54. }
  55. });
  56. }
  57. });
  58. });
  59. observer.observe(document.querySelector("#MiddleColumn"), { subtree: true, childList: true });
  60. });

QingJ © 2025

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