function {{JS_PREFIX}}_apply_blocks(blocked_users) {
    const comments = document.querySelector('#comments');
    if (comments === null || comments.length === 0) {
        console.warn('No comments found, not filtering');
        return;
    }
    {{JS_PREFIX}}_consider_block(comments.querySelectorAll('article.blog-comment'), blocked_users);
}

function {{JS_PREFIX}}_consider_block(comments, blocked_users) {
    if (comments && comments.length && comments.length > 0) {
        for (let i=0; i<comments.length; i++) {
            const comment = comments[i];
            const userElement = comment.querySelector('h3.comment-author');
            if (userElement !== null) {
                const author = userElement.innerText;
                if (blocked_users !== null && blocked_users.includes(author)) {
                    comment.parentNode.removeChild(comment);
                    continue;
                }

                if (userElement.parentNode.querySelector('.bubble_block') === null) {
                    const blockNode = document.createElement('span');
                    blockNode.className = "bubble_block";
                    blockNode.style['white-space'] = 'nowrap';
                    blockNode.innerHTML = '[<b><a href="#" onclick="{{JS_PREFIX}}_block_user(\'' + author.replace("'", "\\\'") + '\'); return false;">X</a></b>]&nbsp;&nbsp;';
                    userElement.parentNode.insertBefore(blockNode, userElement);
                }
            }
        }
    }
}
