Fix Window Height of USA Today Games

Prevents the top and bottom of the embedded game windows (iframes) on USA Today's site from being cut off as they currently are.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Fix Window Height of USA Today Games
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Prevents the top and bottom of the embedded game windows (iframes) on USA Today's site from being cut off as they currently are.
// @author       Koolstr
// @match        https://games.usatoday.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=usatoday.com
// @grant        none
// ==/UserScript==


//Overrides game's iframe height to always be at its max.
(function() {
  'use strict';
	window.addEventListener('load', () => { //Not using window.onload since that doesn't trigger when navigating history with browser's Back/Forward buttons.
		console.log("Overriding game's iframe height.")
		//Using guesstimate timeout since window completes its load event before iframe finishes loading in as well, and this override only works after iframe completes its initial load.
		//Height needs to be set this way as raw style instead of height attribute since some of the games have their forced height values hardcoded as style overrides themselves, which can only be overriden the same way.
		setTimeout(() => document.querySelector('div#game-canvas > iframe')?.setAttribute('style', 'height: 100%'), 8000)
	})
})();