NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Skypech Avatar zoomer // @namespace http://0xbd.cf/ // @version 0.1 // @description try to take over the world! // @author You // @match http://skypech.com/* // @grant none // @copyright 2016+, 0xBADDCAFE // ==/UserScript== (function() { 'use strict'; // http://d.hatena.ne.jp/nextliteracy/20110624/1308889602 function is_child_of(child, parent) { if (child != null) { while (child.parentNode) { if ((child = child.parentNode) == parent) { return true; } } } return false; } function nestedMouseOver(ev, callback) { if (this !== ev.relatedTarget && !is_child_of(ev.relatedTarget, this)) callback.call(this, ev); }; let zoomUp = function(avatar, overCallback) { avatar.parentNode.removeEventListener("mouseover", overCallback); let orig = { "height": avatar.height, "width": avatar.width, "styleHeight": avatar.style.height, "styleWidth": avatar.style.width, "pHeight": avatar.parentNode.style.height, "ppHeight": avatar.parentNode.parentNode.style.height, } avatar.removeAttribute("height"); avatar.removeAttribute("width"); avatar.style.height = "100%"; avatar.style.width = "100%"; avatar.parentNode.style.height = "initial"; avatar.parentNode.parentNode.style.height = "initial"; let outCallback = function(ev) { nestedMouseOver.call(this, ev, function() { avatar.height = orig.height; avatar.width = orig.width; avatar.style.height = orig.styleHeight; avatar.style.width = orig.styleWidth; avatar.parentNode.style.height = orig.pHeight; avatar.parentNode.parentNode.style.height = orig.ppHeight; avatar.parentNode.parentNode.removeEventListener("mouseout", outCallback); avatar.parentNode.addEventListener("mouseover", overCallback); }); }; avatar.parentNode.parentNode.addEventListener("mouseout", outCallback); }; let avatars = document.getElementsByClassName("avatar lazy"); Array.prototype.forEach.call(avatars, function(avatar) { var overCallback = function() { zoomUp(avatar, overCallback); }; avatar.parentNode.addEventListener("mouseover", overCallback); }); })();