Spritecow显示坐标

输出当前鼠标位置相对于选中的精灵图中心点的坐标值

目前为 2022-01-30 提交的版本。查看 最新版本

// ==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
// ==/UserScript==

(function() {
    'use strict';
    document.getElementsByClassName("toolbar-bottom-container")[0].innerHTML += "<div id='dian'>鼠标X轴:<input id='x' type=text><br>鼠标Y轴:<input id='y' type=text><br></div>";
    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;
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址