From 478a84cc0be9357f5cf0b47c0b55669967519a1e Mon Sep 17 00:00:00 2001 From: Vladimir Carrer Date: Wed, 2 Sep 2020 12:30:45 +0200 Subject: [PATCH] New big update --- README.md | 6 ++++++ index.js | 8 ++++++++ package.json | 6 +++--- 3 files changed, 17 insertions(+), 3 deletions(-) mode change 100755 => 100644 index.js diff --git a/README.md b/README.md index 1164301..cb97182 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,8 @@ Parameters: --no - exclude "image", "stylesheet", "script", "font" --click - example: ".selector>a" excellent way to close popups or to click some buttons on the page. --file - output file name (optional, otherwise based on page title and timestamp) +--theme - switch to dark or light color theme +--vd - Emulate vision deficiency 'achromatopsia', 'deuteranopia', 'protanopia', 'tritanopia', 'blurredVision', and 'none'

Example:

@@ -75,6 +77,10 @@ screenshoteer --url https://www.economist.com/ --click ".ribbon__close-button" screenshoteer --url file:///Users/../index.html screenshoteer --url https://www.slashdot.org --file /tmp/slashdot.png + +screenshoteer --url https://mxb.dev/blog/color-theme-switcher/ --theme dark + +screenshoteer --url https://news.ycombinator.com --vd blurredVision ```

List of of supported mobile devices: https://github.com/GoogleChrome/puppeteer/blob/master/DeviceDescriptors.js

diff --git a/index.js b/index.js old mode 100755 new mode 100644 index f20fab9..3a36dd7 --- a/index.js +++ b/index.js @@ -18,6 +18,8 @@ program .option('--no, [no]', 'Exclude') .option('--click, [click]', 'Click') .option('--file, [file]', 'Output file') + .option('--theme, [theme]', 'Color Theme light or dark') + .option('--vd, [vd]', 'Emulate vision deficiency') .parse(process.argv); if (!program.url) { @@ -58,6 +60,12 @@ console.log(program.fullPage); if (program.h && !program.fullpage) program.fullPage = false; await page.setViewport({width: Number(newWidth), height: Number(newHeight)}) } + if (program.theme) { + await page.emulateMediaFeatures([{ name: 'prefers-color-scheme', value: program.theme }]); + } + if (program.vd) { + await page.emulateVisionDeficiency(program.vd); + } if (program.emulate) await page.emulate(devices[program.emulate]); else diff --git a/package.json b/package.json index 104d966..5a0ba7b 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,17 @@ { "name": "screenshoteer", - "version": "1.0.9", + "version": "1.1.0", "description": "Make screenshots and device emulations form your terminal", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "bin": { - "screenshoteer": "./index.js" + "screenshoteer": "index.js" }, "dependencies": { "commander": "^2.19.0", - "puppeteer": "^1.10.0" + "puppeteer": "^4.00.0" }, "keywords": [ "screenshots",