Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.