Go away telegram-freeloader!

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==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);