Skip to content

Instantly share code, notes, and snippets.

@justdanpo
Last active November 14, 2016 07:21
Show Gist options
  • Save justdanpo/a08a101e0a0079957f8b5da75295fa7f to your computer and use it in GitHub Desktop.
Save justdanpo/a08a101e0a0079957f8b5da75295fa7f to your computer and use it in GitHub Desktop.
Center Image
// ==UserScript==
// @name Center Image
// @namespace https://gist.github.com/justdanpo
// @version 0.2
// @description Open images centered
// @author den_po
// @match http://*/*
// @match https://*/*
// @match file://*
// @run-at document-end
// @grant none
// ==/UserScript==
(function() {
if ((1 === document.body.childNodes.length) &&
("IMG" === document.body.childNodes[0].nodeName) &&
(document.body.childNodes[0].src == document.URL)
) {
document.body.style.display = "-webkit-box";
document.body.style.textAlign = "-webkit-center";
document.body.style.webkitBoxAlign = "center";
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment