This is work in progress.
This Node script opens an HTML file in Puppeteer, transforms it, and saves the transformed HTML file.
-
Install dependendies:
- install node modules by running
npm install
in this folder - install Puppeteer by running
npm install puppeteer
.
- install node modules by running
-
Follow the instructions below for transforming an online page or a local one.
Run:
node transform.js --url http://full/url/of/mypage.html --action myaction
The transformed file will be saved as _output/transformed.html
.
-
Save the HTML file you want to transform to this folder.
-
Serve this folder at
http://127.0.0.1:8080
(e.g. with Node's http-server). This is necessary because Puppeteer needs to access the file over HTTP. -
Run this script with:
node transform.js --url mypage.html --action myaction
The transformed file will be saved to _output/transformed.html
.
To create further actions, follow the cleanMathJax
or nerdc
example in transform.js
:
- write new functions at
// Page functions available
, and - run them in response to command-line actions at
// Run page functions
.