pryscraper/stealth_scripts/human_mouse.js
cryptorugmunch 8d25702eca chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth)
Squashed from chore/license-relicense. Full message preserved in the
original branch commit bb77eb5. See ADR-0002 for the decision rationale.

Refs: ADR-0002, commit bb77eb5
2026-07-02 19:59:18 +02:00

36 lines
No EOL
2 KiB
JavaScript

// SPDX-License-Identifier: BSL-1.1
// Copyright (c) 2026 Rug Munch Media LLC
//
// Part of Pry — Stealth Script.
// Licensed under Business Source License 1.1 — see LICENSE-BSL-STEALTH.
(() => {
window.__pry_mouse = { x: 0, y: 0, clicks: 0 };
document.addEventListener('mousemove', (e) => {
window.__pry_mouse.x = e.clientX;
window.__pry_mouse.y = e.clientY;
});
window.__pry_humanClick = async (selector) => {
const el = document.querySelector(selector);
if (!el) return;
const rect = el.getBoundingClientRect();
const targetX = rect.left + rect.width / 2 + (Math.random() - 0.5) * 10;
const targetY = rect.top + rect.height / 2 + (Math.random() - 0.5) * 10;
const steps = Math.floor(Math.random() * 10) + 15;
for (let i = 0; i <= steps; i++) {
const t = i / steps;
const x = window.__pry_mouse.x + (targetX - window.__pry_mouse.x) * (1 - Math.pow(1 - t, 3));
const y = window.__pry_mouse.y + (targetY - window.__pry_mouse.y) * (1 - Math.pow(1 - t, 3));
el.dispatchEvent(new MouseEvent('mousemove', { clientX: x, clientY: y, bubbles: true }));
await new Promise(r => setTimeout(r, Math.random() * 30 + 10));
}
el.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
await new Promise(r => setTimeout(r, Math.random() * 100 + 50));
el.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));
await new Promise(r => setTimeout(r, Math.random() * 50 + 20));
el.dispatchEvent(new MouseEvent('mouseup', { bubbles: true }));
el.dispatchEvent(new MouseEvent('click', { bubbles: true }));
window.__pry_mouse.clicks++;
};
})();