Powered by Blogger.

How to Block Spam Comments in Blogger



There are several reasons for you wants to block a commenter in a blog who frequently posts comments that are considered unethical, abusive, and defamatory.

These comments which contain an invitation in the form of links, hoping for visited links entered into the comments. to avoid these things, you need to enter a specific code into your blog template. Here's how the application works:

The first way with jQuery

Go to Blogger> Template> Edit HTML> Add the following code before the </ body>
<script type='text/javascript'>//<![CDATA[ var spamlist=[ 'http://www.blogger.com/profile/xxxxx', /* url of the commenter */ 'http://nama_blog.blogspot.com/xxxxx', 'http://www.blogger.com/profile/xxxxx' /* last url does not need a comma */];for(var v=0; v<spamlist.length; v=v+1){ $("a[href='"+spamlist[v]+"']").each(function(){ $(this).closest(".comment-block").find(".comment-content") .replaceWith("<div class='comment-content' style='color:red'>You have been banned! Please leave this blog!</div>"),     $(this).replaceWith("<span style='color:red'>BANNED USER!</span>");
For those who use templates to hack commenting system, could use this code
<script type='text/javascript'>//<![CDATA[ var spamlist=[ 'http://www.blogger.com/profile/xxxxx', /* url of the commenter */ 'http://www.blogger.com/profile/xxxxx', 'http://www.blogger.com/profile/xxxxx' /* last url does not need a comma */];for(var v=0; v<spamlist.length; v=v+1){ $("a[href='"+spamlist[v]+"']").each(function(){ $(this).closest(".comment_inner").find(".comment_body") .replaceWith("<div class='.comment_body' style='color:red'>You have been banned! Please leave this blog!</div>"),     $(this).replaceWith("<span style='color:red'>BANNED USER!</span>"); })}//]]></script>
Replace highlighted URLs and texts with your taste. And save the template.

How to do with Conditional tags

Go to Blogger> Template> Edit HTML> Find the code below
<b:loop values='data:post.comments' var='comment'>
Then add this code below the above code
<!--blacklist--><b:if cond='data:comment.authorUrl != &quot;http://www.blogger.com/profile/xxxxx&quot;'><!--blacklist-->
Change http://www.blogger.com/profile/xxxxx with URL will be banned. After you get this code </b:loop> , and add this below code before it:
<!--blacklist-->  </b:if><!--blacklist-->
That's it! Save the template. Thanks for reading!

0 comments:

Post a Comment