Remove Communities from Pikabu

Удаляет посты из сообществ, попавшие в Горячее.

  1. // ==UserScript==
  2. // @name Remove Communities from Pikabu
  3. // @version 0.6
  4. // @description Удаляет посты из сообществ, попавшие в Горячее.
  5. // @author Neur0toxine
  6. // @license WTFPL
  7. // @include *//pikabu.ru/*
  8. // @grant GM_addStyle
  9. // @grant GM_info
  10. // @namespace https://greatest.deepsurf.us/users/12790
  11. // @run-at document-start
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. if(/\/(story\/[a-z0-9_]*)?_[0-9]*/.test(window.location.pathname)) return;
  17. var cssText = '.search-result-communities, .best_comm, ';
  18. cssText += 'a[href="http://pikabu.ru/communities"][class="no_ch"], ';
  19. cssText += 'td[class="rating_bl b-community-top-caption"] {display:none!important}';
  20. if(typeof GM_addStyle != "undefined") GM_addStyle(cssText);
  21. else if(typeof PRO_addStyle != "undefined") PRO_addStyle(cssText);
  22. else if(typeof addStyle != "undefined") addStyle(cssText);
  23. else {
  24. var node = document.createElement("style");
  25. node.type = "text/css";
  26. node.appendChild(document.createTextNode(cssText));
  27. var heads = document.getElementsByTagName("head");
  28. if (heads.length > 0) heads[0].appendChild(node);
  29. else document.documentElement.appendChild(node);
  30. }
  31.  
  32. function remove_posts_by_communities_tag() {
  33. function selhtml(sel,html,proc){for(var t=document.querySelectorAll(sel),i=0;i<t.length;i++)html.test(t[i].innerHTML)&&eval("t[i]."+proc)}
  34. function selproc(sel,proc){for(var t=document.querySelectorAll(sel),i=0;i<t.length;i++)eval("t[i]."+proc)}
  35. selproc('a[href="http://pikabu.ru/communities"][class="no_ch"]','remove();');
  36. selproc('td[class="rating_bl b-community-top-caption"]','closest(\'div\').remove();');
  37. selproc('a[href^="/community"]','closest(\'.story\').remove();');
  38. selproc('.story__sponsor,.story__gag-nice,div[data-story-id="_"]','closest(\'.story\').remove();');
  39. $(document).ajaxComplete(function(){selproc('.story__sponsor,.story__gag-nice','closest(\'.story\').remove();');});
  40. selhtml('td.rating_bl.menu-block-title', /О\sсообществе/, 'closest(\'div\').remove();');}
  41. window.onload = function(){
  42. $(document).ajaxComplete(remove_posts_by_communities_tag);
  43. remove_posts_by_communities_tag();
  44. console.log('['+GM_info.script.name+']: Выполнена очистка!');
  45. };
  46. })();