Skip to content

Instantly share code, notes, and snippets.

@Farow
Last active May 17, 2016 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Farow/b521d91d3cff53f95a21 to your computer and use it in GitHub Desktop.
Save Farow/b521d91d3cff53f95a21 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Transformice fullscreen
// @namespace https://github.com/Farow/userscripts
// @description Fullscreen mode for transformice
// @include http://transformice.com/
// @include http://www.transformice.com/
// @version 1
// @grant none
// ==/UserScript==
let hide_scrollbar = 0;
try {
init();
}
catch (error) {
console.log(error);
}
function init() {
let object = document.getElementById('swf1');
if (!object) {
return;
}
if (hide_scrollbar) {
document.body.style.setProperty('overflow', 'hidden');
}
document.body.style.setProperty('margin-top', set_height(object) + 'px');
object.style.setProperty('position', 'absolute');
object.style.setProperty('top', '0');
object.style.setProperty('left', '0');
object.style.setProperty('z-index', '-1');
object.parentElement.style.setProperty('height', '0');
object.parentElement.parentElement.style.setProperty('height', '0');
let separator = object.parentElement.parentElement.nextElementSibling;
separator.parentElement.removeChild(separator);
set_height(object);
window.addEventListener('resize', set_height.bind(undefined, object));
}
function set_height(object) {
document.body.style.setProperty('margin-top', window.innerHeight + 'px');
object.setAttribute('height', calc_height() + 'px');
}
function calc_height() {
let window_height = window.innerHeight,
swf_height = 600
;
if (window_height < swf_height) {
return swf_height;
}
console.log(window_height + (window_height - swf_height));
return window_height + (window_height - swf_height);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment