Youtube live comments regex filter

Filter youtube live comments. Removes comments with japanese characters by default.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

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

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

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

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Youtube live comments regex filter
// @name:ru      Youtube фильтр комментариев трансляций
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Filter youtube live comments. Removes comments with japanese characters by default.
// @description:ru Фильтрует комментарии youtube трансляций. По умолчанию скрывает комментарии с японскими иероглифами.
// @author       dark1103
// @include      https://www.youtube.com/*
// @icon         https://www.google.com/s2/favicons?domain=youtube.com
// @grant        none
// @require http://code.jquery.com/jquery-3.4.1.min.js
// ==/UserScript==

(function() {
    'use strict';

    var reg = /^.*([一-龠]+|[ぁ-ゔ]+|[ァ-ヴー]+|[々〆〤]+).*$/u;

    $('yt-live-chat-app').find('YT-LIVE-CHAT-TEXT-MESSAGE-RENDERER').each(function(e){
        var target = $(e.target);
        target.find('#message').each(function(ee){
            var text = $(this).text();
            if(reg.test(text)){
                target.hide();
            }
        });
    });


    $('yt-live-chat-app').bind("DOMSubtreeModified", function(e) {
        var target = $(e.target);
        if(target.prop("tagName") === 'YT-LIVE-CHAT-TEXT-MESSAGE-RENDERER'){
            target.find('#message').bind("DOMSubtreeModified", function(ee) {
                var text = $(this).text();
                if(reg.test(text)){
                    target.hide();
                }
            });
        }
    });
})();