Sure, here's a simple text-based Five Nights at Freddy's fan game written in JavaScript and enclosed in script tags within a single HTML file:
Please note that this is a very basic implementation and doesn't include any visual elements or advanced gameplay mechanics. It's intended as a starting point for further development. Feel free to enhance it with graphics, sound effects, or additional gameplay features according to your preferences.