4 lines
10 KiB
JavaScript
4 lines
10 KiB
JavaScript
async(page)=>{const base='http://127.0.0.1:50480',pages=[{"id": "resources", "path": "/resources/"}, {"id": "privacy", "path": "/privacy/"}, {"id": "sources", "path": "/sources/"}, {"id": "accessibility", "path": "/accessibility/"}, {"id": "uikit", "path": "/ui-kit/"}],reps=[{"id": "home", "path": "/", "width": 320, "theme": "light", "status": 200, "title": "ProgCode — записки о программировании", "h1": "Разобраться.Написать. Проверить.", "scrollWidth": 320, "bodyChars": 0, "canvas": "rgb(246, 244, 239)", "h1Width": 288, "h1ScrollWidth": 288, "failedImages": [], "figures": 0, "tableRows": 0, "tableColumns": 0, "downloads": 0, "hasFalseMBHint": false, "top": "/tmp/progcode-ds-content/home-320-light-top.png"}, {"id": "a0", "path": "/articles/использование-jquery-в-webpack/", "slug": "использование-jquery-в-webpack", "width": 320, "theme": "light", "status": 200, "title": "JavaScript. Использование jQuery в Webpack — ProgCode", "h1": "JavaScript. Использование jQuery в Webpack", "scrollWidth": 320, "bodyChars": 2824, "bodyWidth": 288, "fontSize": "18px", "lineHeight": "30.96px", "bodyColor": "rgb(36, 37, 33)", "canvas": "rgb(246, 244, 239)", "h1Width": 288, "h1ScrollWidth": 288, "failedImages": [], "figures": 0, "tableRows": 0, "tableColumns": 0, "downloads": 0, "hasFalseMBHint": false}, {"id": "a1", "path": "/articles/bitrix-api-add-foto-editor/", "slug": "bitrix-api-add-foto-editor", "width": 320, "theme": "light", "status": 200, "title": "Bitrix API. Вставка на страницу встроенного редактора картинок — ProgCode", "h1": "Bitrix API. Вставка на страницу встроенного редактора картинок", "scrollWidth": 320, "bodyChars": 2387, "bodyWidth": 288, "fontSize": "18px", "lineHeight": "30.96px", "bodyColor": "rgb(36, 37, 33)", "canvas": "rgb(246, 244, 239)", "h1Width": 288, "h1ScrollWidth": 288, "failedImages": [], "figures": 2, "tableRows": 0, "tableColumns": 0, "downloads": 0, "hasFalseMBHint": false}, {"id": "a2", "path": "/articles/о-tilix-и-d-интервью-с-геральдом-нанном/", "slug": "о-tilix-и-d-интервью-с-геральдом-нанном", "width": 320, "theme": "light", "status": 200, "title": "О Tilix и D: интервью с Геральдом Нанном — ProgCode", "h1": "О Tilix и D: интервью с Геральдом Нанном", "scrollWidth": 320, "bodyChars": 21566, "bodyWidth": 288, "fontSize": "18px", "lineHeight": "30.96px", "bodyColor": "rgb(36, 37, 33)", "canvas": "rgb(246, 244, 239)", "h1Width": 288, "h1ScrollWidth": 288, "failedImages": [], "figures": 1, "tableRows": 0, "tableColumns": 0, "downloads": 0, "hasFalseMBHint": false}, {"id": "a6", "path": "/articles/ошибка-php-ssl-certificate-error-unable-to-get-local-issuer-certificate/", "slug": "ошибка-php-ssl-certificate-error-unable-to-get-local-issuer-certificate", "width": 320, "theme": "light", "status": 200, "title": "Ошибка PHP. SSL certificate error: unable to get local issuer certificate — ProgCode", "h1": "Ошибка PHP. SSL certificate error: unable to get local issuer certificate", "scrollWidth": 320, "bodyChars": 2422, "bodyWidth": 288, "fontSize": "18px", "lineHeight": "30.96px", "bodyColor": "rgb(36, 37, 33)", "canvas": "rgb(246, 244, 239)", "h1Width": 288, "h1ScrollWidth": 288, "failedImages": [], "figures": 1, "tableRows": 0, "tableColumns": 0, "downloads": 0, "hasFalseMBHint": false, "top": "/tmp/progcode-ds-content/a6-320-light-top.png"}, {"id": "a7", "path": "/articles/dconf-2017-под-капотом-мусорщика-ди-дмитрий-ол/", "slug": "dconf-2017-под-капотом-мусорщика-ди-дмитрий-ол", "width": 320, "theme": "light", "status": 200, "title": "DConf-2017. Под капотом мусорщика D (Дмитрий Ольшанский) — ProgCode", "h1": "DConf-2017. Под капотом мусорщика D (Дмитрий Ольшанский)", "scrollWidth": 320, "bodyChars": 13239, "bodyWidth": 288, "fontSize": "18px", "lineHeight": "30.96px", "bodyColor": "rgb(36, 37, 33)", "canvas": "rgb(246, 244, 239)", "h1Width": 288, "h1ScrollWidth": 288, "failedImages": [], "figures": 2, "tableRows": 0, "tableColumns": 0, "downloads": 0, "hasFalseMBHint": false}, {"id": "a8", "path": "/articles/пишем-аналог-функции-php-preg_match_all-на-языке-прог/", "slug": "пишем-аналог-функции-php-preg_match_all-на-языке-прог", "width": 320, "theme": "light", "status": 200, "title": "Пишем аналог функции PHP preg_match_all на языке программирования D — ProgCode", "h1": "Пишем аналог функции PHP preg_match_all на языке программирования D", "scrollWidth": 320, "bodyChars": 5932, "bodyWidth": 288, "fontSize": "18px", "lineHeight": "30.96px", "bodyColor": "rgb(36, 37, 33)", "canvas": "rgb(246, 244, 239)", "h1Width": 288, "h1ScrollWidth": 288, "failedImages": [], "figures": 0, "tableRows": 0, "tableColumns": 0, "downloads": 0, "hasFalseMBHint": false, "top": "/tmp/progcode-ds-content/a8-320-light-top.png"}, {"id": "a9", "path": "/articles/новый-движок-ctfe/", "slug": "новый-движок-ctfe", "width": 320, "theme": "light", "status": 200, "title": "Dlang. Новый движок CTFE — ProgCode", "h1": "Dlang. Новый движок CTFE", "scrollWidth": 320, "bodyChars": 5644, "bodyWidth": 288, "fontSize": "18px", "lineHeight": "30.96px", "bodyColor": "rgb(36, 37, 33)", "canvas": "rgb(246, 244, 239)", "h1Width": 288, "h1ScrollWidth": 288, "failedImages": [], "figures": 1, "tableRows": 4, "tableColumns": 3, "downloads": 0, "hasFalseMBHint": false}, {"id": "a10", "path": "/articles/особенности-vibe-d/", "slug": "особенности-vibe-d", "width": 320, "theme": "light", "status": 200, "title": "Особенности Vibe.d — ProgCode", "h1": "Особенности Vibe.d", "scrollWidth": 320, "bodyChars": 18188, "bodyWidth": 288, "fontSize": "18px", "lineHeight": "30.96px", "bodyColor": "rgb(36, 37, 33)", "canvas": "rgb(246, 244, 239)", "h1Width": 288, "h1ScrollWidth": 288, "failedImages": [], "figures": 1, "tableRows": 0, "tableColumns": 0, "downloads": 0, "hasFalseMBHint": false}, {"id": "a11", "path": "/articles/вирус-самопроизвольный-запуск-брауз/", "slug": "вирус-самопроизвольный-запуск-брауз", "width": 320, "theme": "light", "status": 200, "title": "Вирус. Самопроизвольный запуск браузера и перенаправление на вредоносные сайты. — ProgCode", "h1": "Вирус. Самопроизвольный запуск браузера и перенаправление на вредоносные сайты.", "scrollWidth": 320, "bodyChars": 2848, "bodyWidth": 288, "fontSize": "18px", "lineHeight": "30.96px", "bodyColor": "rgb(36, 37, 33)", "canvas": "rgb(246, 244, 239)", "h1Width": 288, "h1ScrollWidth": 288, "failedImages": [], "figures": 1, "tableRows": 0, "tableColumns": 0, "downloads": 0, "hasFalseMBHint": false, "top": "/tmp/progcode-ds-content/a11-320-light-top.png"}, {"id": "a13", "path": "/articles/привет-мир/", "slug": "привет-мир", "width": 320, "theme": "light", "status": 200, "title": "Привет, мой читатель! — ProgCode", "h1": "Привет, мой читатель!", "scrollWidth": 320, "bodyChars": 301, "bodyWidth": 288, "fontSize": "18px", "lineHeight": "30.96px", "bodyColor": "rgb(36, 37, 33)", "canvas": "rgb(246, 244, 239)", "h1Width": 288, "h1ScrollWidth": 288, "failedImages": [], "figures": 0, "tableRows": 0, "tableColumns": 0, "downloads": 0, "hasFalseMBHint": false}],results=[],errors=[],external=[];page.on('pageerror',e=>errors.push(String(e)));page.on('request',r=>{if(!r.url().startsWith(base)&&!r.url().startsWith('data:'))external.push(r.url());});
|
||
for(const width of [320,390,1440])for(const theme of ['light','dark'])for(const c of pages){await page.setViewportSize({width,height:1000});await page.emulateMedia({colorScheme:theme,reducedMotion:'reduce'});const res=await page.goto(base+c.path,{waitUntil:'networkidle'});await page.getByLabel('Тема',{exact:true}).selectOption(theme);await page.evaluate(()=>document.fonts.ready);let row=await page.evaluate(()=>({doc:document.documentElement.scrollWidth,width:innerWidth,h1:{text:document.querySelector('h1').innerText,font:getComputedStyle(document.querySelector('h1')).fontSize,client:document.querySelector('h1').clientWidth,scroll:document.querySelector('h1').scrollWidth},text:document.querySelector('main').innerText,footer:document.querySelector('footer').innerText,footerLinks:[...document.querySelectorAll('footer a')].map(a=>({text:a.innerText,url:a.getAttribute('href')})),failedImages:[...document.images].filter(i=>!i.complete||!i.naturalWidth).map(i=>i.src),fields:[...document.querySelectorAll('input,textarea')].map(e=>({id:e.id,width:e.getBoundingClientRect().width,cls:e.className})),download:document.querySelectorAll('[download]').length}));row={...c,width,theme,status:res.status(),...row};await page.screenshot({path:'/tmp/progcode-ds-cm-f5/'+c.id+'-'+width+'-'+theme+'-top.png'});await page.evaluate(()=>window.scrollTo({top:document.body.scrollHeight,behavior:'instant'}));await page.screenshot({path:'/tmp/progcode-ds-cm-f5/'+c.id+'-'+width+'-'+theme+'-footer.png'});results.push(row);}
|
||
for(let i=0;i<reps.length;i++){let c=reps[i];const width=i%3===0?1440:i%3===1?320:390,theme=i%2?'light':'dark';await page.setViewportSize({width,height:1000});await page.emulateMedia({colorScheme:theme,reducedMotion:'reduce'});const res=await page.goto(base+c.path,{waitUntil:'networkidle'});await page.getByLabel('Тема',{exact:true}).selectOption(theme);await page.screenshot({path:'/tmp/progcode-ds-cm-f5/'+c.id+'-'+width+'-'+theme+'-representative.png'});results.push({...c,width,theme,status:res.status(),...await page.evaluate(()=>({doc:document.documentElement.scrollWidth,body:document.querySelector('.article-content')?.textContent.length,failedImages:[...document.images].filter(i=>!i.complete||!i.naturalWidth).map(i=>i.src)}))});}
|
||
return{source:'f5d92794816398171b68a1d374b24bd0cd9ea0f85d005c7be92369b40d314900',build:'ea4fb0dc8934776e4e9d4213f07c27424962789bfadd1ba9ca51ad31d5736851',base,results,errors,external};} |