<commit_before>function filterComment(pattern, comment) {
    var jComment = $(comment);
    // Fixme apparently there is no way of knowing whether this is our own message or someone else's
    //if (jComment.hasClass('author-viewing')) return; // don't remove your own comments
    if (pattern.test(jComment.find("#message").text().trim())) {
        jComment.remove();
    }
}

function include_chat_filter(settings) {
    if (settings.blockedTerms.termString == '') return;
    YouTubeLive.onChatLoaded(function(youtube) {
        var pattern;
        if (settings.blockedTerms.isRegex) {
            pattern = new RegExp(settings.blockedTerms.termString);
        } else {
            pattern = new RegExp(settings.blockedTerms.termString.split(/\s+/).map(escapeRegExp).join("|"));
        }

        youtube.registerChatMessageObserver(function (elem) {
            filterComment(pattern, elem);
        }, true);
    });
}

function escapeRegExp(str) {
    return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}<commit_msg>don't filter your own messages<commit_after>function filterComment(pattern, comment) {
    var jComment = $(comment);
    // Fixme apparently there is no way of knowing whether this is our own message or someone else's
    //if (jComment.hasClass('author-viewing')) return; // don't remove your own comments
    if (pattern.test(jComment.find("#message").text().trim())) {
        jComment.remove();
    }
}

function include_chat_filter(settings) {
    if (settings.blockedTerms.termString == '') return;
    YouTubeLive.onChatLoaded(function(youtube) {
        var ownName = $("yt-live-chat-message-input-renderer").find("#author-name").text();

        var pattern;
        if (settings.blockedTerms.isRegex) {
            pattern = new RegExp(settings.blockedTerms.termString);
        } else {
            pattern = new RegExp(settings.blockedTerms.termString.split(/\s+/).map(escapeRegExp).join("|"));
        }

        youtube.registerChatMessageObserver(function (elem) {
            // don't delete your own messages
            if ($(elem).find("#author-name").text() == ownName) return;
            filterComment(pattern, elem);
        }, true);
    });
}

function escapeRegExp(str) {
    return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}
{'fraction_non_alphanumeric': 0.17026793431287812, 'fraction_numerical': 0.0, 'mean_word_length': 2.845514950166113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6770670', 'n_tokens_mistral': 693, 'n_tokens_neox': 674, 'n_words': 136}