obtain mouse coordinates through chrome extension

后端 未结 4 1529
夕颜
夕颜 2021-02-06 11:22

I am curious to know if there is a way to get the mouse coordinates through a chrome extension and then use these coordinates to check if the person has clicked in that position

4条回答
  •  庸人自扰
    2021-02-06 11:41

    I was so tired of searching for an answer to this every few weeks so I created a quick script. It requires jquery for dom selection, dom appending, and style editing.. this could be easily changed, but i've already worked too much this week.

    (function() {
        'use strict';
        var $toolTip = $('
    '); $toolTip.addClass('customTooltip-rsd') .css({ position: 'absolute', display: 'inline-block', 'font-size': '22px', backgroundColor: '#000', color: '#ffffff', 'z-index': 9999999999, padding: '10px', 'word-spacing': '10px', 'border-radius': '50%', width: 100, height: 100, 'line-height': '100px', 'text-align': 'center', 'font-weight': 'bold' }) ; $(document.body).append($toolTip); $(window).on('mousemove', function(e) { var posX = e.pageX; var posY = e.pageY; $toolTip.text(posX + ',' + posY).css({ top: posY + 'px', left: posX + 'px' }); }); }());

提交回复
热议问题