Game stolen? This could help you!

0

Stats

1,971 visits, 2,613 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 24 Sep, 2014. Last updated 19 Feb, 2019

[this works also with iframed games!]

Have your games ever been "stolen"?

I've published some games on Kongregate and on some other similar websites.

After a while, searching for one of my games on google, I've discovered that some "freegames" websites were showing my game as their!

For one of those websites was easy to contact the admin and he kindly linked the game to my Kongregate page removing his iframe. But some chinese website didn't want to take it down.

Even changing the game location on my server wasn't useful because they monitor every Kongregate game's change to copy the correct iframe link.

What can we do about this?

If you want your game to be playable only on some websites just add the following lines to your "index.html"

            <script>
        		$(document).ready(function(){
        			var d = document.referrer;var b = 'http://www.yourwebsite.foo';
        			if(d!=b) window.top.location.href = b; 
        		});
        	</script>

Code explanation:

When the page is loaded save the url of the current page into the variable "d", save into "b" what the url should be like and if the url of the current page is not the expected url then redirect to the expected url.

Where should I put it?

I usually put this snippet here (inside "index.html"):

Live Example

(maybe one of your games is here too!)

- chinese website (game stealer)

So...

This is not the most secure way to protect your games...but is something!

You can add more websites on your "whitelist":

        <script>
            	$(document).ready(function(){
            		var d = document.referrer;
        			var b = 'http://www.yourwebsite.foo';
        			var c = 'http://www.othersite.foo';
            		if(d!=b) window.top.location.href = b;
            		else if(d!=c) window.top.location.href = c;
            	});
            </script>

You could also obfuscate this code to make it nearly unreadable:

        var _0xc099=["\x72\x65\x66\x65\x72\x72\x65\x72","\x68\x74\x74\x70\x3A\x2F\x2F\x77\x77\x77\x2E\x79\x6F\x75\x72\x77\x65\x62\x73\x69\x74\x65\x2E\x66\x6F\x6F","\x68\x72\x65\x66","\x6C\x6F\x63\x61\x74\x69\x6F\x6E","\x74\x6F\x70","\x72\x65\x61\x64\x79"];$(document)[_0xc099[5]](function (){var _0x6874x1=document[_0xc099[0]];var _0x6874x2=_0xc099[1];if(_0x6874x1!=_0x6874x2){window[_0xc099[4]][_0xc099[3]][_0xc099[2]]=_0x6874x2;} ;} );
    

You can find Javascript obfuscators online just searching on google.

I've used this one.

Feel free to ask if you need anything!

  • 0 Comments

Want to leave a comment? Login or Register an account!