Last active
January 12, 2018 10:36
-
-
Save Loksly/a94bdee1b01ede819b2c2472f9ab95e1 to your computer and use it in GitHub Desktop.
Chrome easter egg, T-Rex for waiting rooms and so.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
T-Rex J. | |
T-Rex for waiting rooms and so. | |
see how it works: https://youtu.be/-D2s_9RCOrw | |
go this url: chrome://network-error/-106 | |
press ctrl + shift + j | |
paste the code below and enjoy what you watch */ | |
(function(){ | |
'use strict'; | |
var timeout, | |
r = window.Runner(); | |
function tryToJump(){ | |
r.onKeyDown({preventDefault: function(){}, target:'', type: window.Runner.events.TOUCHSTART, currentTarget: r.containerEl }); | |
} | |
function fullWidthZoom(){ | |
//default width of .runner-canvas is 600px | |
var width = document.body.clientWidth, | |
scale = (width / 6); /* (width * 100/600) */ | |
document.body.style.zoom = scale + '%'; | |
document.head.innerHTML = document.head.innerHTML + '<style>h1, #main-message, #suggestions-list, .error-code {display: none } document, body { overflow:hidden}</style>'; | |
} | |
function tick(){ | |
var nextObstacle = r.horizon.obstacles && r.horizon.obstacles.length > 0 | |
? r.horizon.obstacles[0] : false; | |
if (typeof r.currentSpeed === 'number' && | |
nextObstacle && | |
nextObstacle.xPos < r.currentSpeed * 19 && | |
!r.tRex.jumping){ | |
if (nextObstacle.yPos > 60){ | |
tryToJump(); | |
} | |
} | |
if (!r.activated || r.crashed){ | |
if (r.crashed){ | |
tryToJump(); /* clearInterval(timeout); */ | |
} | |
} | |
} | |
fullWidthZoom(); | |
tryToJump(); | |
timeout = setInterval(tick, 10); | |
})(); | |
/* | |
This is just a toy written by Loksly (https://github.com/Loksly) just for fun. | |
Original T-Rex Runner code can be found at the link below. Check there for the credits and license. | |
https://chromium.googlesource.com/chromium/src.git/+/master/components/neterror/resources/offline.js | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment