Last active
January 18, 2019 02:31
-
-
Save stripedpurple/ef4d8e4e15542e32601fda8d0021db5f to your computer and use it in GitHub Desktop.
Simple User script that gives the dimensions of the current window.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Window Dimensions | |
// @namespace http://stripedpurple.io | |
// @version 2.0 | |
// @description adds a dimension list to screen | |
// @author Austin Barrett | |
// @match *://localhost/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var createDimensions = function() { | |
var dimension = document.createElement("span"); // Create a <button> element | |
dimension.setAttribute("id", "myDimensions"); | |
var t = document.createTextNode((function() { | |
var w = window.innerWidth; | |
var h = window.innerHeight; | |
return w + ' x ' + h; | |
})()); | |
dimension.appendChild(t); | |
dimension.style.background = "#333"; | |
dimension.style.color = "white"; | |
dimension.style.position = "fixed"; | |
dimension.style.bottom = "0"; | |
dimension.style.right = "0"; | |
dimension.style.zIndex = "100000"; | |
dimension.style.padding = "3px"; | |
dimension.style.fontSize = "12px"; | |
dimension.style.fontFamily = "Arial"; | |
document.body.appendChild(dimension); | |
}; | |
var updateDimensions = function() { | |
var w = window.innerWidth; | |
var h = window.innerHeight; | |
document.getElementById("myDimensions").innerHTML = w + ' x ' + h; | |
}; | |
window.onload = createDimensions; | |
window.onresize = updateDimensions; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment