Very nifty!
I've gone through the code, looks clean. Thanks for this!
Thanks.
Yeah, it's clean... but uh, sort of "weak." I made it for personal usage out of boredom.
Anyway, to save anyone time, here's the source of it... I'm sure anyone could greatly improve it.
// ==UserScript==
// @name Bitcoin Monitor Full Screen
// @namespace none
// @description Adds a full screen button to bottom right corner.
// @include http://bitcoinmonitor.com/
// @include http://bitcoinmonitor.com/#
// @include http://www.bitcoinmonitor.com/
// @include http://www.bitcoinmonitor.com/#
// ==/UserScript==
var bFS = false;
var scale = 0.95;
var container = document.getElementById('content');
var graph = document.getElementById('placeholder');
var slider = document.getElementById('slider_box');
var elems = document.getElementsByTagName('*');
var toggleBtn = document.createElement('a');
var defaults = Array();
var bDefaultsSet = false;
function showExcess(bShow) {
var disp = bShow ? '' : 'none';
for (var i = 0; i < elems.length; i++) {
var e = elems[i];
if (e.tagName == 'HEADER' || e.tagName == 'FOOTER') {
e.style.display = disp;
}
if (e.hasAttribute('class')) {
var cls = e.getAttribute('class');
if (cls.indexOf('wrapper') != -1 || cls.indexOf('body3') != -1) {
e.style.display = disp;
}
}
}
}
function doResize() {
if (bFS) {
var scaleWidth = window.innerWidth * scale;
var scaleHeight = window.innerHeight * scale;
container.style.width = parseInt(scaleWidth) + 'px';
container.style.height = parseInt(scaleHeight) + 'px';
container.style.left = parseInt((window.innerWidth / 2) - (scaleWidth / 2)) + 'px';
container.style.top = parseInt((window.innerHeight / 2) - (scaleHeight / 2)) + 'px';
}
unsafeWindow.refresh_viewport();
}
function toggleFS() {
if (!bDefaultsSet) {
defaults['gw'] = graph.style.width;
defaults['gh'] = graph.style.height;
defaults['cw'] = container.style.width;
defaults['ch'] = container.style.height;
defaults['ct'] = container.style.top;
defaults['cl'] = container.style.left;
defaults['cp'] = container.style.position;
defaults['bg'] = document.body.style.background;
bDefaultsSet = true;
}
showExcess(bFS);
bFS = !bFS;
if (bFS) {
toggleBtn.textContent = 'Full Screen [on ]';
document.body.style.background = '#FFFFFF';
container.style.position = 'fixed';
container.style.top = '0px';
container.style.left = '0px';
graph.style.width = '100%';
graph.style.height = '100%';
window.addEventListener('resize', doResize, false);
} else {
window.removeEventListener('resize', doResize, false);
document.body.style.background = defaults['bg'];
container.style.position = defaults['cp'];
container.style.top = defaults['ct'];
container.style.left = defaults['cl'];
container.style.width = defaults['cw'];
container.style.height = defaults['ch'];
graph.style.width = defaults['gw'];
graph.style.height = defaults['gh'];
toggleBtn.textContent = 'Full Screen [off]';
}
doResize();
}
toggleBtn.href = '#';
toggleBtn.textContent = 'Full Screen [off]';
toggleBtn.style.position = 'fixed';
toggleBtn.style.bottom = '0px';
toggleBtn.style.right = '0px';
toggleBtn.style.zIndex = 9;
toggleBtn.style.fontFamily = 'monospace';
document.body.insertBefore(toggleBtn, document.body.lastChild);
toggleBtn.addEventListener('click', toggleFS, false);
I don't expect it to be used much, but I figured it would be better to share just in case someone wants to use it :-/
Thanks for your time, and for your comment Beremat.