import fs from 'node:fs'; import {connectRealAccountWebView} from '../../scripts/lib/real-account-webview.mjs'; const {cdp}=await connectRealAccountWebView(); try{ const snapshot=await cdp.evaluate(async()=>{if(location.pathname!=='/login'||!document.querySelector('#login-refinement-preview'))throw Error('不在登录原型页');const clone=document.querySelector('app-mb-login-page').cloneNode(true);clone.querySelectorAll('input').forEach(x=>{x.removeAttribute('value');x.value=''});clone.querySelectorAll('script').forEach(x=>x.remove());clone.querySelectorAll('*').forEach(x=>[...x.attributes].filter(a=>/^on/i.test(a.name)).forEach(a=>x.removeAttribute(a.name)));const styles=[];for(const sheet of [...document.styleSheets]){if(sheet.ownerNode?.tagName==='STYLE')styles.push(sheet.ownerNode.textContent);else if(sheet.href&&new URL(sheet.href).origin===location.origin)styles.push(await(await fetch(sheet.href)).text())}return{markup:clone.outerHTML,css:styles.join('\n'),htmlAttributes:[...document.documentElement.attributes].filter(a=>['class','style','data-palette','data-accent'].includes(a.name)).map(a=>[a.name,a.value])}}); const base='file:///E:/work/fmode-app/test-results/real-account-20261130/build-r2/project/www/browser/'; const css=snapshot.css.replace(/url\((['"]?)\/(?!\/)/g,(_,q)=>'url('+q+base); const attrs=snapshot.htmlAttributes.map(([k,v])=>k+'="'+v.replaceAll('&','&').replaceAll('"','"')+'"').join(' '); const file='prototypes/login-refinement-20261130/index.html'; fs.writeFileSync(file,'