// ==UserScript== // @name Spritecow显示坐标 // @namespace Siner // @version 1.0 // @description 输出当前鼠标位置相对于选中的精灵图中心点的坐标值 // @author Siner // @match http://*/* // @license Siner // @include *spritecow.com/* // @icon http://www.spritecow.com/assets/9/favicon.ico // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; document.getElementsByClassName("toolbar-bottom-container")[0].innerHTML += "
鼠标X轴:
鼠标Y轴:
"; function mouseMove(ev) { ev = ev || window.event; var t1 = document.getElementsByClassName("highlight")[0] var mousePos = mouseXY(ev); var x = Number(t1.style.width.substr(0,t1.style.width.length - 2)) / 2 + Number(t1.style.left.substr(0,t1.style.left.length - 2)) + 20; var y = Number(t1.style.height.substr(0,t1.style.height.length - 2)) / 2 + Number(t1.style.top.substr(0,t1.style.top.length - 2)) + 60; document.getElementById('x').value = mousePos.x - x; document.getElementById('y').value = mousePos.y - y; } function mouseXY(ev) { if (ev.pageX || ev.pageY) { return { x: ev.pageX, y: ev.pageY }; } return { x: ev.clientX + document.body.scrollLeft - document.body.clientLeft, y: ev.clientY + document.body.scrollTop - document.body.clientTop }; } document.onmousemove = mouseMove; })();