(function () {
const rnd = (a, b) => a + Math.floor(Math.random() * (b - a + 1));
const W = 1920;
const H = 1080;
let active = true;
let x = rnd(1, W);
let y = rnd(1, H - 60);
let outCb = null;
let overCb = null;
async function fakeOverOut() {
let n = 2;
while (active && n-- > 0) {
await new Promise((r) => setTimeout(r, rnd(50, 150)));
const d = { clientX: x, clientY: y, screenX: x, screenY: y - 13 };
if (outCb) outCb(new MouseEvent('mouseout', d));
if (overCb) overCb(new MouseEvent('mouseover', d));
}
}
async function fakeMove(cb) {
let n = 4;
while (active && n-- > 0) {
await new Promise((r) => setTimeout(r, rnd(50, 200)));
x += rnd(2, 20);
y += rnd(4, 27);
cb(
new MouseEvent('mousemove', {
clientX: x,
clientY: y,
screenX: x,
screenY: y - 13,
})
);
}
}
const doMove = rnd(0, 10) > 2;
const doOver = rnd(0, 10) > 2;
__zdReplace(Document.prototype, 'addEventListener', (orig) =>
function (type, cb) {
try {
if (typeof cb === 'function') {
if (doMove && type === 'mousemove') fakeMove(cb);
else if (doOver && type === 'mouseout') {
outCb = cb;
if (overCb) fakeOverOut();
} else if (doOver && type === 'mouseover') {
overCb = cb;
if (outCb) fakeOverOut();
}
}
} catch (e) {
}
return orig.apply(this, arguments);
}
);
__zdReplace(Document.prototype, 'removeEventListener', (orig) =>
function () {
active = false;
return orig.apply(this, arguments);
}
);
})();