License your game to domain(s), protect your games.

Favourite 13 favourites
Tutorial written by stctrOriginally published on 21st, February 2015 - 4 revisions

License your game to domain(s), protect your games.

Notice this isn't 100% protective but offers a good solution.

1. Export your game (HTML5).
2. Open index.html file in editor (notepad++)
3. Find <body> tag.
4. Copy and paste under <body> tag:

    var referrer = document.domain; // The result of referrer will be:
    if(referrer == ""){ 
     // Use || for multiple domains like : if(referrer == "" || ""){ 
    window.myValue = true;
    document.write("Access denied");
    window.myValue = false;

5. When you are done setting up the domains go to :
6. Paste your code & click the obfuscate button:

7. Copy everything and change it with your current code under <body>
Like :

    var _0x5217=["\x64\x6F\x6D\x61\x69\x6E","\x77\x77\x77\x2E\x79\x6F\x75\x72\x64\x6F\x6D\x61\x69\x6E\x2E\x63\x6F\x6D","\x6D\x79\x56\x61\x6C\x75\x65","\x41\x63\x63\x65\x73\x73\x20\x64\x65\x6E\x69\x65\x64","\x77\x72\x69\x74\x65"];var referrer=document[_0x5217[0]];if(referrer==_0x5217[1]){window[_0x5217[2]]=true}else {document[_0x5217[4]](_0x5217[3]);window[_0x5217[2]]=false;};

8. Find <script src="c2runtime.js"></script>
9. Replace it with :

    var _$_4a06=["\x6D\x79\x56\x61\x6C\x75\x65","\x3C\x73\x63\x72\x69\x70\x74\x20\x73\x72\x63\x3D\x22\x63\x32\x72\x75\x6E\x74\x69\x6D\x65\x2E\x6A\x73\x22\x3E\x3C\x2F\x73\x63\x72\x69\x70\x74\x3E","\x77\x72\x69\x74\x65"];if(window[_$_4a06[0]]==true){var _0xe376=[_$_4a06[1],_$_4a06[2]];document[_0xe376[1]](_0xe376[0]);};</script>

10. Save your index.html & control if it's working

Don't forget to post feedback : )

For geeks after you did the process above

If you want to make it really hard for people to steal & use your games use :

JS obfuscators:

Unlock your full gamedev potential

Upgrade to the Personal Edition of Construct 2, it has way more features and won't holding back from making money and using your full creativity like the free edition does. It's a one off payment and all Construct 2 editor updates are free for life!

View deals

Plus, it's got a lot of additional features that will help you save time and make more impressive games!

Congratulations on finishing this tutorial!

Did you learn a lot from it? Share it now with your friends!

Share and Copy this Tutorial

You are free to copy, distribute, transmit and adapt this work with correct attribution. Click for more info.

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.