Full Screen for CrazyGames

Refresh page if not working

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Full Screen for CrazyGames
// @namespace   Violentmonkey Scripts
// @match       https://*.crazygames.com/*
// @grant       none
// @version     1.0
// @author      -
// @description Refresh page if not working
// @license CC0
// ==/UserScript==

window.addEventListener('load', async function() {
  if (document.location.hostname === 'www.crazygames.com') {
    await waitForElm('#game-iframe');
    document.location = document.getElementById('game-iframe').src;
  }

  if (document.location.hostname === 'games.crazygames.com' && document.location.pathname.endsWith('/index.html')) {
    await waitForElm('.MuiGrid-container');
    let base = document.getElementsByClassName('MuiGrid-container')[0].parentElement;
    base.querySelectorAll('*').forEach(function(element) {
      if (!element.closest('.MuiGrid-root')) {
        element.style.display = 'none';
      }
    });
  }
}, false);

function waitForElm(selector) {
    return new Promise(resolve => {
        if (document.querySelector(selector)) {
            return resolve(document.querySelector(selector));
        }

        const observer = new MutationObserver(mutations => {
            if (document.querySelector(selector)) {
                observer.disconnect();
                resolve(document.querySelector(selector));
            }
        });

        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    });
}