Custom Black/White Cursor (Finger Tracking)

Pixel-perfect black arrow with white outline. Tracks finger/mouse exactly on iPadOS Safari + desktop browsers.

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Custom Black/White Cursor (Finger Tracking)
// @namespace    https://greasyfork.org/en/users/000000
// @version      1.0
// @description  Pixel-perfect black arrow with white outline. Tracks finger/mouse exactly on iPadOS Safari + desktop browsers.
// @author       NotNightmare
// @match        *://*/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const SIZE = 32; // matches your uploaded cursor proportions

    if (window.__customCursorActive) return;
    window.__customCursorActive = true;

    const style = document.createElement('style');
    style.textContent = `
        html, body {
            cursor: none !important;
        }

        .nn-cursor {
            position: fixed;
            width: ${SIZE}px;
            height: ${SIZE}px;
            pointer-events: none;
            z-index: 999999;
            transform: translate(-2px, -2px); /* aligns tip with real pointer */
        }

        /* White outline (slightly larger arrow behind) */
        .nn-outline {
            position: absolute;
            width: 0;
            height: 0;
            border-style: solid;
            border-width: ${SIZE + 3}px 0 0 ${SIZE + 3}px;
            border-color: transparent transparent transparent white;
            left: -2px;
            top: -2px;
        }

        /* Black fill arrow (main shape) */
        .nn-fill {
            position: absolute;
            width: 0;
            height: 0;
            border-style: solid;
            border-width: ${SIZE}px 0 0 ${SIZE}px;
            border-color: transparent transparent transparent black;
        }

        /* Soft drop shadow like your image */
        .nn-cursor {
            filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.45));
        }
    `;
    document.documentElement.appendChild(style);

    const cursor = document.createElement('div');
    cursor.className = 'nn-cursor';

    const outline = document.createElement('div');
    outline.className = 'nn-outline';

    const fill = document.createElement('div');
    fill.className = 'nn-fill';

    cursor.appendChild(outline);
    cursor.appendChild(fill);
    document.documentElement.appendChild(cursor);

    let x = 0;
    let y = 0;
    let raf = null;

    function update() {
        cursor.style.left = x + 'px';
        cursor.style.top = y + 'px';
        raf = null;
    }

    function move(e) {
        if (e.pointerType === 'touch') return;
        x = e.clientX;
        y = e.clientY;
        if (!raf) raf = requestAnimationFrame(update);
    }

    window.addEventListener('pointermove', move, { passive: true });
    window.addEventListener('mousemove', move, { passive: true });
})();