blacklist habr

Clear the main page of habr.com from blacklisted authors

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

  1. // ==UserScript==
  2. // @name blacklist habr
  3. // @author Nemo (Papageno)
  4. // @namespace Papageno
  5. // @version 1.1
  6. // @description Clear the main page of habr.com from blacklisted authors
  7. // @match https://habr.com/*
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
  9. // @icon http://habr.com/favicon.ico
  10. // @grant GM_log
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. var blacklist=[];
  15. // populate blacklist with you authors
  16. blacklist.push('RationalAnswer');
  17.  
  18. function main(){
  19. const articles = document.querySelectorAll('article');
  20. //GM_log(articles);
  21.  
  22. for(const article of articles){
  23. var author = article.getElementsByClassName('tm-user-info__userpic')[0];
  24. if (typeof author === 'undefined') {
  25. }
  26. else{
  27. var name = author.attributes.getNamedItem('title').value;
  28. if(blacklist.includes(name)){
  29. GM_log(name);
  30. const newDiv = document.createElement("div");
  31. const newContent = document.createTextNode(name);
  32. newDiv.appendChild(newContent);
  33. article.parentElement.appendChild(newDiv);
  34. article.parentNode.removeChild(article);
  35. }
  36. }
  37. }
  38.  
  39. const links = document.querySelectorAll('link');
  40. for(const link of links){
  41. var as = link.getAttribute('as');
  42. if (typeof as === 'undefined') {
  43. }
  44. else{
  45. if ( as === 'script') {
  46. link.parentNode.removeChild(link);
  47. break;
  48. }
  49. }
  50. }
  51. }
  52.  
  53.  
  54. setTimeout(function(){
  55. main();
  56. }, 2000);
  57.  
  58. window.addEventListener(
  59. "scroll", main, false
  60. );
  61.