Files
site-portfolio/cmp2.mjs
T

17 lines
1.0 KiB
JavaScript

import puppeteer from 'puppeteer';
const b = await puppeteer.launch({ args:['--no-sandbox','--disable-setuid-sandbox','--use-gl=angle','--enable-unsafe-swiftshader'] });
const p = await b.newPage();
await p.goto('http://10.200.201.3:4175/_lab/neu-card.html',{waitUntil:'load',timeout:60000});
const probe = async (sel) => p.evaluate((s)=>{
const e = document.querySelector(s); const cs=getComputedStyle(e);
return { bg: cs.backgroundColor, bgImg: cs.backgroundImage.slice(0,55), shadow: cs.boxShadow.split('),').map(x=>x.trim().replace(/rgba\([^)]*\)/,'C')) };
}, sel);
console.log('DARK');
console.log(' neu:', JSON.stringify(await probe('#sec-final .neu-card')));
console.log(' cc :', JSON.stringify(await probe('#sec-contact .contact-card')));
await p.evaluate(()=>document.documentElement.setAttribute('data-theme','light'));
console.log('LIGHT');
console.log(' neu:', JSON.stringify(await probe('#sec-final .neu-card')));
console.log(' cc :', JSON.stringify(await probe('#sec-contact .contact-card')));
await b.close();