Remove Communities from Pikabu

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Remove Communities from Pikabu
// @version      0.6
// @description  Удаляет посты из сообществ, попавшие в Горячее.
// @author       Neur0toxine
// @license      WTFPL
// @include      *//pikabu.ru/*
// @grant        GM_addStyle
// @grant        GM_info
// @namespace    https://greasyfork.org/users/12790
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';
    if(/\/(story\/[a-z0-9_]*)?_[0-9]*/.test(window.location.pathname)) return;
    var cssText = '.search-result-communities, .best_comm, ';
    cssText += 'a[href="http://pikabu.ru/communities"][class="no_ch"], ';
    cssText += 'td[class="rating_bl b-community-top-caption"] {display:none!important}';
    if(typeof GM_addStyle != "undefined") GM_addStyle(cssText);
    else if(typeof PRO_addStyle != "undefined") PRO_addStyle(cssText);
    else if(typeof addStyle != "undefined") addStyle(cssText);
    else {
            var node = document.createElement("style");
            node.type = "text/css";
            node.appendChild(document.createTextNode(cssText));
            var heads = document.getElementsByTagName("head");
            if (heads.length > 0) heads[0].appendChild(node);
            else document.documentElement.appendChild(node);
    }

    function remove_posts_by_communities_tag() {
        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)}
        function selproc(sel,proc){for(var t=document.querySelectorAll(sel),i=0;i<t.length;i++)eval("t[i]."+proc)}
        selproc('a[href="http://pikabu.ru/communities"][class="no_ch"]','remove();');
        selproc('td[class="rating_bl b-community-top-caption"]','closest(\'div\').remove();');
        selproc('a[href^="/community"]','closest(\'.story\').remove();');
        selproc('.story__sponsor,.story__gag-nice,div[data-story-id="_"]','closest(\'.story\').remove();');
        $(document).ajaxComplete(function(){selproc('.story__sponsor,.story__gag-nice','closest(\'.story\').remove();');});
        selhtml('td.rating_bl.menu-block-title', /О\sсообществе/, 'closest(\'div\').remove();');}
    window.onload = function(){
        $(document).ajaxComplete(remove_posts_by_communities_tag);
        remove_posts_by_communities_tag();
        console.log('['+GM_info.script.name+']: Выполнена очистка!');
    }; 
})();