NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name ROTMG Max Client Size // @namespace https://openuserjs.org // @version 0.1 // @description Make the Realm of the Mad God client always fit the page, and removes the sidebars // @author L1lith // @run-at document-load // @match http*://www.realmofthemadgod.com/ // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; const aspectRatio = 3/4 function setGameDimensions(swf) { const pageWidth = window.innerWidth const pageHeight = window.innerHeight const width = Math.min(pageHeight * (1 / aspectRatio), pageWidth) const height = width * aspectRatio console.log(pageWidth, pageHeight, width, height) swf.width = width swf.height = height } async function run() { const clutterElements = ['.media', '.navigation', '.footer'] clutterElements.map(query => document.querySelector(query)).filter(element => element).forEach(element => { element.parentNode.removeChild(element) }) const thanks = [...document.getElementsByTagName('p')].find(element => element.innerText.trim().toLowerCase().startsWith("thanks")) if (thanks) thanks.parentNode.removeChild(thanks) const swf = await awaitElement('.game_swf') window.addEventListener('resize', ()=>setGameDimensions(swf)) setGameDimensions(swf) } function timer(ms) {return new Promise(res => setTimeout(res, ms))} async function awaitElement(querySelector, checkRate=250){ let element = null while (true) { element = document.querySelector(querySelector); if (element) return element await timer(checkRate) } } run().catch(console.error) })();