Block Justin Y.

Hides posts made by Justin Y. on Youtube.

  1. // ==UserScript==
  2. // @name Block Justin Y.
  3. // @match *.youtube.com/*
  4. // @description Hides posts made by Justin Y. on Youtube.
  5. // @version 0.0.1.20190130045008
  6. // @namespace https://gf.qytechs.cn/users/243229
  7. // ==/UserScript==
  8.  
  9. var config = {childList: true, subtree: true };
  10.  
  11. // Waiting for comments section to load
  12. function observeComments1() {
  13. var commentsCallback1 = function(mutationsList, observer) {
  14. let commentsSection = document.getElementById('comments');
  15. if (commentsSection) {
  16. commentObserver1.disconnect();
  17. observeComments2(commentsSection);
  18. }
  19. };
  20. var commentObserver1 = new MutationObserver(commentsCallback1);
  21. commentObserver1.observe(document.body, config);
  22. }
  23.  
  24. // Waiting for comments section inside comments section to load
  25. function observeComments2(commentsSection) {
  26. var commentsCallback2 = function(mutationsList, observer) {
  27. let commentsList = commentsSection.querySelector('#contents');
  28. if (commentsList) {
  29. commentObserver2.disconnect();
  30. observeComments3(commentsList);
  31. }
  32. };
  33. var commentObserver2 = new MutationObserver(commentsCallback2);
  34. commentObserver2.observe(commentsSection, config);
  35. }
  36.  
  37. // Checking comments for username
  38. function observeComments3(commentsList) {
  39. var commentsCallback3 = function(mutationsList, observer) {
  40. for(var mutation of mutationsList) {
  41. mutation.addedNodes.forEach(function(comment) {
  42. let usernameParent = comment.querySelector('#author-text');
  43. let username = usernameParent.children[0].textContent.trim();
  44. if (username == 'Justin Y.' || username == 'add_as_many_names' || username == 'as_you_want_here') {
  45. comment.hidden = true;
  46. console.log('Blocked ' + username);
  47. }
  48. });
  49. }
  50. };
  51. let config2 = {childList: true};
  52. var observer = new MutationObserver(commentsCallback3);
  53. observer.observe(commentsList, config2);
  54. }
  55.  
  56. observeComments1();

QingJ © 2025

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