Mouse Line Aimer for zombsroyale.io

Creates a line that follows the mouse

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Mouse Line Aimer for zombsroyale.io
// @namespace    JonJon565
// @version      1.0
// @description  Creates a line that follows the mouse
// @author       JonJon565|IGN:911
// @match        https://zombsroyale.io/
// @grant        GM_addStyle
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    var line = document.createElement('div');
    line.id = 'cursor-line';
    document.body.appendChild(line);

    GM_addStyle(`
        #cursor-line {
            display: none; /* Initially hide the line */
            position: fixed;
            top: 50%;
            left: 50%;
            width: 150px; /* Set line thickness */
            height: 3px;
            background-color: black;
            z-index: 9999;
            transform-origin: 0 0; /* Set transform origin to top left corner */
        }
    `);
    document.addEventListener('mousemove', function(event) {
        var line = document.getElementById('cursor-line');
        var centerX = window.innerWidth / 2;
        var centerY = window.innerHeight / 2;
        var mouseX = event.clientX;
        var mouseY = event.clientY;
        var deltaX = mouseX - centerX;
        var deltaY = mouseY - centerY;
        var angle = Math.atan2(deltaY, deltaX);
        var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
        line.style.transform = 'translate(0%, 0%) rotate(' + angle + 'rad)';
        line.style.width = distance + 'px';
    });

    document.addEventListener('keydown', function(event) {
        if (event.key === '-') {
            var line = document.getElementById('cursor-line');
            line.style.display = (line.style.display === 'none') ? 'block' : 'none';
        }
    });
})();