Website cloning, or the unauthorized replication of a website’s content, is a prevalent issue on the internet. Not only does it undermine the original site’s authority, but it can also lead to stolen traffic and potential revenue loss. However, with the help of JavaScript, website owners can implement measures to detect and mitigate such unauthorized activities. In this article, we’ll explore how a simple JavaScript code snippet can help prevent website cloning and traffic theft.

Understanding the JavaScript Code:

Let’s dissect the JavaScript code snippet provided:

<script>
var q = top.location.toString();
var domain = "bgtedbgteobgtembgteabgteibgtenbgte.bgtecbgteobgtembgte".toString();
var domain_decrypted = domain.replace(/bgte/gi, "");
if (q.indexOf(domain_decrypted) == -1) {
top.location = "https://google.com";
}
</script>

var q = top.location.toString();

This line retrieves the current page’s URL and stores it in the variable q.

var domain = “bgtedbgteobgtembgteabgteibgtenbgte.bgtecbgteobgtembgte”.toString();

bgtedbgteobgtembgteabgteibgtenbgte.bgtecbgteobgtembgte = domain.com

Here, a string representing the original domain name is stored in the variable domain . Note that the domain name is encrypted for security reasons. You must fill in your domain name but you will also need to add bgte before and after each letter to encrypt your domain.

var domain_decrypted = domain.replace(/bgte/gi, “”);

This line decrypts the domain name by removing the encryption pattern (in this case, “bgte”) from the string, resulting in the original domain name.

if (q.indexOf(domain_decrypted) == -1) {

The script checks if the decrypted domain name is present in the current page’s URL. If it’s not found (indexOf returns -1), it means the page is being accessed from a different domain.

top.location = “https://google.com”;

If the page is accessed from a different domain, the script redirects the user to “https://google.com” (you can replace this with any desired destination).

Preventing Website Cloning:

By embedding this JavaScript code snippet into your website’s pages, you can create a barrier against website cloning attempts. Here’s how it works:

  • Detection: The script detects if the current page is being accessed from a domain other than the original.
  • Action: If a mismatch is detected, the script redirects the user to a predetermined destination, such as your website’s homepage or a designated landing page.

Conclusion: With the help of JavaScript, website owners can implement proactive measures to safeguard against website cloning and traffic theft. By deploying scripts like the one outlined above, you can protect your website’s integrity, retain control over your traffic, and mitigate the risk of revenue loss due to unauthorized replication of your content. Remember to regularly monitor your website’s traffic patterns and take appropriate action against suspicious activity.