Go away telegram-freeloader!

Удаляет ссылки на телегу и ВК.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Go away telegram-freeloader!
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Удаляет ссылки на телегу и ВК.
// @author       notimer
// @match        https://pikabu.ru/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tlgrm.ru
// @grant        none
// @license MIT
// ==/UserScript==
//
// Функция удаления из нод ссылок
function removeTelega(textNodes) {
    for (let blockNode of textNodes) {
        if (blockNode.hasChildNodes()) {
            if (typeof blockNode.childNodes[1] !== 'undefined') {
                blockNode.childNodes[1].querySelectorAll('[href^="https://t.me"],[href^="https://vk.com"],[href*="t.me"],[href*="vk.com"]').forEach(function(elem) {elem.remove();});
            }
        }
    }
}
// Коллбэк при срабатывании мутации
const observerCallback = function(mutationsList, observer) {
    for (let mutation of mutationsList) {
        if (mutation.type !== 'childList')	continue;
        for (let node of mutation.addedNodes) {
            if (node.nodeName === "#text" || node.nodeName === "#comment") continue;
            let storyTelega = node.getElementsByClassName('story-block story-block_type_text');
            removeTelega(storyTelega);
        }
    }
};

let storyTelega = document.getElementsByClassName('story-block story-block_type_text');
removeTelega(storyTelega);

// Обсервер для тех, у кого бесконечная лента
const config = {childList: true, subtree: true};
const observer = new MutationObserver(observerCallback);
observer.observe(document.body, config);