Sure, here's an example code for an endless runner game implemented as a single HTML file using JavaScript and enclosed in script tags:
This code sets up the game canvas, initializes variables, handles key press events, updates the game frame, and calculates the score and highscore. The player can control the character by using the left and right arrow keys. Obstacles will continuously move downwards, and if the player collides with an obstacle, the game ends. The score represents the time survived, and the highscore is displayed at the top left corner of the canvas. The highscore is stored in the browser's local storage for future sessions.