-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_cursor.js
More file actions
30 lines (27 loc) · 958 Bytes
/
patch_cursor.js
File metadata and controls
30 lines (27 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const fs = require('fs');
let code = fs.readFileSync('script.js', 'utf8');
const oldCursor = ` document.addEventListener('mousemove', e => { cx = e.clientX; cy = e.clientY; });
(function loop() {
requestAnimationFrame(loop);
rx += (cx - rx) * 0.12; ry += (cy - ry) * 0.12;
ring.style.left = \`\${rx}px\`; ring.style.top = \`\${ry}px\`;
})();`;
const newCursor = ` let moved = false;
document.addEventListener('mousemove', e => {
cx = e.clientX;
cy = e.clientY;
if (!moved) { rx = cx; ry = cy; moved = true; }
ring.style.opacity = '1';
ring.style.display = 'block';
});
(function loop() {
requestAnimationFrame(loop);
rx += (cx - rx) * 0.12;
ry += (cy - ry) * 0.12;
ring.style.left = rx + 'px';
ring.style.top = ry + 'px';
ring.style.zIndex = '99999';
})();`;
code = code.replace(oldCursor, newCursor);
fs.writeFileSync('script.js', code);
console.log('Cursor always-on-top patched.');