jQuery Hacks : Hiding Links inside Comments

span stopFor the past few months I have been dealing with a lot of spam in the comment section. The Blogger's inbuilt filter has stopped more than 6000 spam comments but still some slipped by . Due to this very reason I had to close the Anonymous option for commenting. But this didn't solve the problem and people with Blogger profile started to spam as well . So I have come up with a simple jQuery powered hack that hides any clickable link and just displays its text.


Demo
Try adding links in the comment below

Code
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'/>
<script>  

$('.comment-content a[rel$=nofollow]').replaceWith(function(){return ($(this).text());});

</script>

Add it just before the </body> tag in the Edit HTML . In case you have already included the jQuery library , then add the code starting from Line 2 onwards.

If you want to completely remove the links from the comments , then use this code instead

<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'/>
<script>  

$('.comment-content a[rel$=nofollow]').hide());

</script>


This works for the Threaded Comments in Blogger , incase you want to make it work for the old Comments in Blogger , then the code is as follows
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'/>
<script>  

$('.comment-body p a[rel$=nofollow]').replaceWith(function(){return ($(this).text());});

</script>


Hope this helps you in curbing the spam in your comment section and feel free to share this simple trick with your friends

Related Articles

Written by Prayag Verma

A self proclaimed Blogger Evangelist. He has been blogging for the past 3 years and likes to help people having problems with Blogger . Get more from Prayag on and Twitter

Email Newsletter

Like what you read here in this post ?
Get new posts delivered straight to your inbox

New comments are not allowed.
Jack Owen said...

it no work

Durai Sankar said...

It works for me:)Thanks a lot!

Anonymous said...

Test Stylifyyourblog

http://www.findastuces.com/

Saurabh said...

WOW ! Nice tweak.
Many times, I found people embedding there links in comments. it will really do a lot of help.
Thanks for Sharing !

More Blog Tools

It's working... But, I can affect the loading of website?

It can affect the loading of the website?

If not, I install this in my site..

www.moreblogtools.com

Thank's a LOT prayag!!!... you solve my headache.. :)

Reply to Jack Owen:
it works, but you must knowing the comments section's class of DIV element on your template.
at first, this code didn't work, because the class of my div element. but when i change the code to $('.comment-block p a[rel$=nofollow]').replaceWith(function(){return ($(this).text());}); according to the class of div element on my template.

[sorry for my bad english :)]

Prayag Verma said...

Hi Jay

I checked your blog , it is already using jQuery library so it will not slow down your blog , you will just have to include the code from Line 2 onwards

Prayag Verma said...

Hi Jack

Here by links I meant clickable links , I suppose there was a misinterpretation of the meaning , sorry for causing the confusion . The reason why hiding or removing non-clickable links is not useful is because they have no real SEO value attached to them. Whereby clickable links even when they are of no-follow nature , the Search Engine does keep track of them - even if they are not counted in the overall SERPs . With the volatile nature of Google algorithms - it is always good to be on the precautionary side

Prayag Verma said...

Hi Ismaïl

I am sorry for causing the confusion , but by links I meant clickable links .
As you can see in the comment just above yours , the Stylifyyourblog part is a real link (You can View the Source to confirm that fact) and it been converted to simple Text

Thank you Prayag for replying my comments. I used this.. This is helpful in spam comments...

ohotech.com said...

<a href="http://www.ohotech.com/>ohotech</a>

testing

hey dude why your blog is not so smooth while scrolling ?

Nirmal Kumar said...

Nice Trick. Worked like a charm. Thanks Prayag.

Anonymous said...

It will help to prevent spammers like Jay Ryan Macabato who almost spam on every blog :/

Hari kesh said...

P.Harikesh

Anonymous said...

Just Testing...
Google

Anonymous said...

also testing

Anonymous said...

yes I agree with you.He also spammed on mybloggertricks and many great sites.

Jay dont spam again.

http://mafiadosfilmes.blogspot.com

brilliant tips,,thanks for making this..you can
Automatically add URL Resources On Copied Articles

Lost-Sector said...

Thanks for this share...!!!

Anonymous said...

goggle link

Gagan Masoun said...

It is working correctly :)

abozakariya said...

thanks for share.

Tanmay Kapse said...

Awesome job
Your Pc Genie

Tushar said...

Smart way to prevent spams. well done.

If I used this hacks, thus Google penalize my site by using this code?
Because it used to hide the links.

www.MoreBlogTools.com

Not functioning in my blog... Please help...

www.MoreBlogTools.com

Awesome ;) Thank You For The Post ....

Regards :

http://www.TheDigitCrunch.com

10Blogger said...

thanks been looking for this ... trying if successful.

Apk said...

Yes, i have been facing this comment problem. Thanks for flagging it.

I will try it. Thanks for the trick it is very helpful in span comments.

Rosa Liebe said...

haha, but if you can still post this, you are maybe no longer linking to spammy sites, but you still have spam comments, which look ugly

yah for sure your post is really helpfull for me.

Its Worked like a charm for me. I am using it on my blog.

Google Adsense MBL Approval Trick 2013

Google Adsense MBL Approval Trick 2013:

http://megabloggerlab.blogspot.com/2012/04/google-adsense-mbl-approval-trick-2013.html

Optimasi SEO said...

wonderful post, i like it, i hope more post in thread comment for blogger. good job

Testing--My Site here still has comment links

Really Awesome Post

Laxman Singh said...

Really Awesome Post

Testing Link :-> Www.Etechentertainment.blogspot.com