7 ms·
JavaScript Code Plays Google Dinosaur/T-Rex Game Automatically
- pcthrowaway 6y agonow they just need to make this an offline chrome app so you can open it when you're offline
- citrusui 6y agoAs long as you have Chrome, you can still play it offline. Just go to chrome://dino
- awesomeideas 6y agoSimulated paleontology is such an amazing field!
- superjan 6y agoCopy-pasting random javascript from the internet is not good security hygene.
- thdc 6y agoEspecially 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)
- truly_furqan 6y agoGreat 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.
- truly_furqan 6y agoI completely agree with your concern. But, I had to make it as simple as possible for non-programmers.
- oplav 6y agoTIL that pressing "down" makes the dinosaur duck.
- ravenstine 6y agoIf you've got a photoresistor and a servo, you can make a "robot" play the dinosaur game manually! https://www.youtube.com/watch?v=L2NtMpQml-A https://www.youtube.com/watch?v=L2NtMpQml-A
- koolba 6y agoI didn’t even know this Dino game existed and suddenly fear that a massive procrastination wave is unfolding.
- nestorD 6y agoI 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!
- jestanoff 6y agoI 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);
- truly_furqan 6y agoThanks 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.
- jestanoff 6y agoMay 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
- bobbydreamer 6y agoNew is edge browsers surfer
- 9214 6y agoThere's also a relatively old Common Lisp solution. https://vitovan.com/dino.html https://vitovan.com/dino.html
- truly_furqan 6y agoHmm, nice one. Thanks for mentioning.
- Gaelan 6y agoHere's a quick deobfuscated version (pretty printed, renamed variables, converted foo && (bar(), baz()) to if(foo) {bar(); baz()}). https://gist.github.com/Gaelan/a0c5461055437dca9618a12f68949ce6 https://gist.github.com/Gaelan/a0c5461055437dca9618a12f68949...
- Gaelan 6y agoEdit: 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.
- truly_furqan 6y agoThat's cool. I appreciate that.