How to Block Spam Comment Bots in Blogger

Advertisements
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.
Advertisements

The Editorial Team of MyBloggerLab consists of a group of Professional Blogger geeks Led by Syed Faizan Ali (Founder of MyBloggerLab).

Comment With:
OR
Choose Wisely!

2 comments

July 17, 2016 at 7:32 PM

Hello, congratulations for this tutorial. I was waiting a long time how to block spam in blog comments system. It´s works fine on my blog!
The only issue is that this script works only for the web template, but do not works for de mobile template blogger.
So, if you use a smartphone to acess your blog, spam comments from baned users is still there.
It would be nice if could work to mobile template too.
Thanks in advance.

July 17, 2016 at 11:17 PM

Woow Awesome post. This is really helpfull for me. You made my day. I just loved this article. You helped me alot so I just wanna say thanks to you.
Thank you.

Post a Comment

We’re eager to see your comment. However, Please Keep in mind that all comments are moderated manually by our human reviewers according to our comment policy, and all the links are nofollow. Using Keywords in the name field area is forbidden. Let’s enjoy a personal and evocative conversation.

Helping You to do Cool Things With Blogger Since 2012™.

© Copyright 2012 - 2018. MBL Networks, All Rights are Strictly Reserved.