HackingUniversity - Hacks . Tricks . How-To's

15 July 2012

Automatically Add Attribution Link to Copied Text in Blogger

blogger logoUnique content is the main key to success in blogging line and if that thing is also stolen from you that you are left with nothing, well there are many ways of copying out the content and leaving no traces but still we some measures we can take and protect our content from getting stolen like we have earlier posted on how you can disable dragging in your blogger blog and also making right click disabled and also a great article on CSS Hack for protecting your articles from getting copied but to take a step further we found an amazing script which you can use in your blogger or wordpress blogs and it will act automatically by adding an attribution link to the copied text.


So as you can see in the above image there’s a Source line in the end of the text that line will be added automatically when anyone copies the text from your post, so if he copies the post from the specific post URL that URL will be added as the source so pretty cool huh !. So now if you wanna this feature to your website than just follow the below steps and you will have it working on your blogger or your wordpress blog.

1. Go to Blogger > Layout > Add a Gadget

2. Now just add the below script to it.

<script type='text/javascript'>
function addLink(){var a=document.getElementsByTagName("body")[0];var b;b=window.getSelection();var c="<br/><br/> Source : <a href='"+document.location.href+"'>"+document.location.href+"</a><br/>Content Copyrighted to HackingUniversity.in";var d=b+c;var e=document.createElement("div");e.style.position="absolute";e.style.left="-99999px";a.appendChild(e);e.innerHTML=d;b.selectAllChildren(e);window.setTimeout(function(){a.removeChild(e)},0)}document.oncopy=addLink

3. Now just edit the lines in red color to whatever you wanna display and that’s it save your gadget and drag it to the bottom of the template.

4. Now refresh your blog and open any post and try to copy the text and paste it in any notepad or blogger post page and you will see that Source line right below of that copied text.