Richardcsts Posted July 11, 2019 Share Posted July 11, 2019 Today I was playing a game made in javascript, and in the game files I had several javascript files and one communicating with the other being that they all started as follows (function(){ //Codigo })(); How do I create separate files from the current one and all starting with this code so that nobody can access the function via the google chrome console? Quote Link to comment Share on other sites More sharing options...
jonforum Posted July 11, 2019 Share Posted July 11, 2019 in window.onload You can use promise and async loader But you can alway access to all , it just because they are hiding somewhere . It why people use tool like `obfuscator` or `minify all in one file` and make all hard to debug in a dist projet. (async () => { //# libs await loadJS('js/libs/0' ); await loadJS('js/libs/1' ); await loadJS('js/libs/2' ); //# core await loadJS('js/game'); //! editor await loadJS('js/editor'); //#TODO: Decryptor, //#JSON,CSV, await $loader.initialize(); $app.initialize(); })(); and the part of promise , but this is just a example simple example from my side. function loadJS(path) { return new Promise((resolve, rej) => { const reader = eval("require('recursive-readdir')"); reader(path, [], (err, files) => { files = files.filter(f => f.split('.').length<3 ); // filter(remove) les clones vscode .1.js,.2.js files.sort((a, b) => a.replace(/_/g, ' ').localeCompare(b.replace(/_/g, ' '))); // sort file with '_' first const head = document.getElementsByTagName('head')[0]; function next() { const path = files.shift() if(!path){ return resolve() }; const type = path.indexOf('.js')>-1; // true:js, false:css const el = document.createElement(type?'script':'link'); el.setAttribute("type", type?"text/javascript":"text/css"); el.setAttribute("rel", type?"scriptSheet":"stylesheet"); type? el.setAttribute("src", path) : el.setAttribute("href", path); el.onload = function() { next() }; head.appendChild(el); }; next(); }); }) }; A good alternative is use `nwjs` or `electron` without sdk to remove dev tool. But web version, you can alway put breakpoint or debug thing, you can juste made this more complexe to understand. Great example on most online browser game, you can use `Tampermonkey` or `Cheat Engine ` for flash game, to inject script and cheat online web game. Richardcsts 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.