20 comments

[ 2.2 ms ] story [ 52.7 ms ] thread
now they just need to make this an offline chrome app so you can open it when you're offline
As long as you have Chrome, you can still play it offline. Just go to chrome://dino
Simulated paleontology is such an amazing field!
Copy-pasting random javascript from the internet is not good security hygene.
Especially when it's minimized like this. Are they trying to hide something? Why couldn't it be formatted in a more readable manner?

(it does look safe though)

Great point!

But actually, I minified this code so that people can quickly try it out. I'll try to explain it in some other article.

I completely agree with your concern.

But, I had to make it as simple as possible for non-programmers.

TIL that pressing "down" makes the dinosaur duck.
I didn’t even know this Dino game existed and suddenly fear that a massive procrastination wave is unfolding.
I have a t-shirt that features the Google T-Rex Game and I found that a large number of people do not recognisee the dinosaur nor know the game despite using chrome daily!
I don't like the length of their solution, quite the same logic can be shortened to just a few lines of code

setInterval(() => {

  const { currentSpeed, horizon: { obstacles: [{ xPos, width, yPos } = {}] } } = Runner?.instance_;

  if (xPos < 25 * currentSpeed - width && yPos >= 75)
    document.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 32 }));
}, 100);
Thanks for mentioning this code. Actually, I've just tried your solution. But, the dinosaur dies quickly.

So, I think the code I mentioned in the article is more efficient.

May be it is something small as dividing the width by 2 and setting a lower milliseconds value for the setinterval so it runs the checks more often.

Essentially this is the same solution as in the post, just stripped down to the bare minimum of code, but I haven't tested it enough. There must be some edge case that it fails on

Here's a quick deobfuscated version (pretty printed, renamed variables, converted foo && (bar(), baz()) to if(foo) {bar(); baz()}).

https://gist.github.com/Gaelan/a0c5461055437dca9618a12f68949...

Edit: after I did that, I discovered jsnice.org, which managed to do all the deobfuscation I did (including inferring variable names from usage!) automatically. I'm very impressed. I replaced the gist above with the JSNice output.