How to Block Spam Comment Bots in Blogger

Spam Comments can cause a real trouble if they are not prevented. To block spam comments, bloggers take strict actions by asking people to register, enter a captcha or answer a random question before leaving a comment. However, these spam prevention techniques make it difficult for your daily visitors to comment because re-entering a weird captcha every time you make a comment is a real pain. Majority of Spam comment is made by bots, which are designed to leave spammy comments on blogs and websites. Today in this article, we will show you how to block spam comment bots in Blogger.


How Comment Spam Bots Work?

Blogger (service) is a used by millions of blogs and websites. Therefore, all these websites uses the same Blogger commenting system unless they are using a third-party commenting system. This means, it makes it a lot easier for spam bots to find blogs and post spam comments.

Some spam bots are smart enough to fill captcha and flexible enough to answer different questions to fool the website's spam prevention system. This means, the best way to tackle spam bots is to completely block them from commenting on your website.

Method#1: Blocking Spam Bots in Blogger Using b:if Condition

In the first method, we will block bots using b: if condition. Therefore, to ban a user from commenting on your site, you have to find his Blogger Profile URL and using b: if condition stop him from accessing comment form. This will blacklist a specific user's Blogger profile and he will no longer be able to make or see any comments on your site.
  1. To find a user's Blogger Profile URL, go to your comment section and left click on the names of the comment posters.

  2. Now list of options will be appear, from the list select "Copy link address" as it is shown in the screenshot below:
  3. After copying the profile URL, go to Blogger >> Template >> Edit HTML >> Search for </body> and just below it paste the following code:

  4. <b:if cond='data:comment.authorUrl!= &quot;https://www.blogger.com/profile/XXXXXXXXXX"' >
    <script>
     $(".comment-form").replaceWith("<p style=" color: #111; text-align: center; border: 1px solid #d2d2d2; padding: 13px; font-size: 15px; ">You are Banned from Commenting on this site</p>");
    </script>
    </b:if>

  5. Now in the above code, replace https://www.blogger.com/profile/XXXXXXXXXX with the Blogger profile URL you copied earlier. Keep in mind this will ban only one user to ban more users you have to paste the above code again in your template but with different profile URL.

  6. Once everything is done, save the template. Take a look at the screenshot below to the results:

Method#2: Blocking Spam bots in Blogger with jQuery:

In the second method, we will block bots using jQuery.
  1. Go to Blogger >> Template >> Edit HTML >> search for the ending </body> tag and right above it paste the following jQuery code:

  2. <script type='text/javascript'>
        //<![CDATA[
        //Block Spam Comment Bots in Blogger
        //Black List Blogger Profiles
        var spamlist = [
            'https://www.blogger.com/profile/XXX', //First Ban User
            'https://www.blogger.com/profile/XXX', //Second Ban User
            'https://www.blogger.com/profile/XXX' //Third Ban User
        ];


        for (var v = 0; v < spamlist.length; v = v + 1) {
            $("a[href='" + spamlist[v] + "']").each(function() {
                $(this).closest(".comment-block").find(".comment-actions, .datetime, .comment-replybox-thread, .comment-block")
                    .replaceWith("");
                $(this).closest(".comment-block").find(".comment-content")
                    .replaceWith("<div class='comment-content' style='color:red'>This user's comment has been removed!</div>");
                $(this).replaceWith("<span style='color:red'>BANNED USER!</span>");
            })
        }
        //]]>
    </script>

  3. Now in the above code, replace https://www.blogger.com/profile/XXX with the Blogger profile URL that you would like to ban. You can ban unlimited users by adding profile links in the above codes.

  4. Once everything is done, press "Save Template". Take a look at the screenshot below to the results:
We hope this tutorial has helped you in learning how to block spam comments bots in blogger. Let us know what do you think about this plugin in the comments below.

Post a Comment

0 Comments