@@ -56,14 +56,66 @@ async function createContext(
5656 recording : RecordingConfig ,
5757 outputDir : string
5858) : Promise < BrowserContext > {
59- return browser . newContext ( {
59+ const context = await browser . newContext ( {
6060 recordVideo : {
6161 dir : outputDir ,
6262 size : recording . viewport ,
6363 } ,
6464 viewport : recording . viewport ,
6565 deviceScaleFactor : recording . deviceScaleFactor ,
6666 } ) ;
67+
68+ if ( recording . showMouseClicks !== false ) {
69+ await context . addInitScript ( buildMouseClickOverlayScript ( ) ) ;
70+ }
71+
72+ return context ;
73+ }
74+
75+ function buildMouseClickOverlayScript ( ) : string {
76+ return `(() => {
77+ const style = document.createElement('style');
78+ style.textContent = \`
79+ .gg-cursor {
80+ width: 16px; height: 16px; border-radius: 50%;
81+ background: rgba(255, 80, 0, 0.85);
82+ border: 2px solid white;
83+ position: fixed; pointer-events: none; z-index: 999999;
84+ transform: translate(-50%, -50%);
85+ transition: left 30ms linear, top 30ms linear;
86+ box-shadow: 0 0 4px rgba(0,0,0,0.4);
87+ }
88+ @keyframes gg-ripple {
89+ from { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
90+ to { transform: translate(-50%, -50%) scale(3.5); opacity: 0; }
91+ }
92+ .gg-ripple {
93+ width: 24px; height: 24px; border-radius: 50%;
94+ border: 3px solid rgba(255, 80, 0, 0.9);
95+ position: fixed; pointer-events: none; z-index: 999998;
96+ animation: gg-ripple 500ms ease-out forwards;
97+ }
98+ \`;
99+ document.head.appendChild(style);
100+
101+ const cursor = document.createElement('div');
102+ cursor.className = 'gg-cursor';
103+ document.body.appendChild(cursor);
104+
105+ document.addEventListener('mousemove', (e) => {
106+ cursor.style.left = e.clientX + 'px';
107+ cursor.style.top = e.clientY + 'px';
108+ });
109+
110+ document.addEventListener('click', (e) => {
111+ const ripple = document.createElement('div');
112+ ripple.className = 'gg-ripple';
113+ ripple.style.left = e.clientX + 'px';
114+ ripple.style.top = e.clientY + 'px';
115+ document.body.appendChild(ripple);
116+ setTimeout(() => ripple.remove(), 500);
117+ });
118+ })();` ;
67119}
68120
69121async function executeScript ( script : string , page : Page , _baseUrl : string ) : Promise < void > {
0 commit comments