From 6ddc23027aea0cb6f27144dfdcf67ee458892959 Mon Sep 17 00:00:00 2001 From: user Date: Mon, 14 Jun 2021 10:28:27 -0700 Subject: [PATCH 01/10] version bump to v0.3.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0160e6d..6602cc8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "timesnap", - "version": "0.3.0-prerelease", + "version": "0.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7993e88..605eb49 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "timesnap", - "version": "0.3.0-prerelease", + "version": "0.3.0", "description": "Take screenshots of web pages at smooth intervals", "repository": { "type": "git", From ac3a1af2ff02f8c37be3ddf0c43c18311e9c2845 Mon Sep 17 00:00:00 2001 From: user Date: Mon, 14 Jun 2021 10:31:01 -0700 Subject: [PATCH 02/10] version bump to v0.3.1-prerelease --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6602cc8..313419b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "timesnap", - "version": "0.3.0", + "version": "0.3.1-prerelease", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 605eb49..2d755f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "timesnap", - "version": "0.3.0", + "version": "0.3.1-prerelease", "description": "Take screenshots of web pages at smooth intervals", "repository": { "type": "git", From c882eee462d1db880eb42aa30ddc3336c0b6f6ef Mon Sep 17 00:00:00 2001 From: user Date: Fri, 13 Aug 2021 09:35:23 -0700 Subject: [PATCH 03/10] added support for `page.addInitScript` if available --- lib/overwrite-random.js | 4 +++- lib/overwrite-time.js | 3 ++- lib/utils.js | 9 +++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/overwrite-random.js b/lib/overwrite-random.js index fafc0b3..ffefc0f 100644 --- a/lib/overwrite-random.js +++ b/lib/overwrite-random.js @@ -30,6 +30,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +const { evaluateOnNewDocument } = require('./utils.js'); + // unrandomizer seed constants // default seed values are only used if all of the seed values end up being 0 const defaultSeed1 = 10; @@ -61,7 +63,7 @@ const overwriteRandom = function (page, unrandom, log) { }; const overwritePageRandom = function (page, seed1 = 0, seed2 = 0, seed3 = 0, seed4 = 0) { - return page.evaluateOnNewDocument(function (config) { + return evaluateOnNewDocument(page, function (config) { (function (exports) { let shift1 = 23; let shift2 = 17; diff --git a/lib/overwrite-time.js b/lib/overwrite-time.js index 69eb8cd..ad9cdaa 100644 --- a/lib/overwrite-time.js +++ b/lib/overwrite-time.js @@ -31,13 +31,14 @@ */ const fs = require('fs'); const path = require('path'); +const { evaluateOnNewDocument } = require('./utils.js'); const timewebLib = fs.readFileSync( path.join(require.resolve('timeweb/dist/timeweb.js')), { encoding: 'utf8' } ); const overwriteTime = async function (page) { - return page.evaluateOnNewDocument(timewebLib); + return evaluateOnNewDocument(page, timewebLib); }; const goToTime = async function (browserFrames, time) { diff --git a/lib/utils.js b/lib/utils.js index b8e2c3d..6864d86 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -41,6 +41,14 @@ const getBrowserFrames = function (frame) { return [frame].concat(...frame.childFrames().map(getBrowserFrames)); }; +const evaluateOnNewDocument = function (page, fn) { + if (page.evaluateOnNewDocument) { + page.evaluateOnNewDocument(fn); + } else if (page.addInitScript) { + page.addInitScript(fn); + } +}; + const getSelectorDimensions = async function (page, selector) { return page.evaluate(function (selector) { var el = document.querySelector(selector); @@ -116,6 +124,7 @@ const makeFileDirectoryIfNeeded = function (filepath) { module.exports = { getBrowserFrames, + evaluateOnNewDocument, getSelectorDimensions, writeFile, stringArrayFind, From e94c809c4b8243ef266695dd5abf2e2b51cda498 Mon Sep 17 00:00:00 2001 From: user Date: Sat, 14 Aug 2021 00:51:39 -0700 Subject: [PATCH 04/10] adds support for getViewportSize and setViewportSize note that playwright's `page.setViewportSize` does not support deviceScaleFactor --- index.js | 8 ++++---- lib/capture-screenshot.js | 4 ++-- lib/utils.js | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index d98d4ea..910740b 100644 --- a/index.js +++ b/index.js @@ -35,7 +35,7 @@ const path = require('path'); const defaultDuration = 5; const defaultFPS = 60; const { overwriteRandom } = require('./lib/overwrite-random'); -const { getBrowserFrames, stringArrayFind } = require('./lib/utils'); +const { getBrowserFrames, stringArrayFind, getPageViewportSize, setPageViewportSize } = require('./lib/utils'); module.exports = async function (config) { config = Object.assign({}, config || {}); @@ -155,13 +155,13 @@ module.exports = async function (config) { if (config.viewport || scaleArg) { config.viewport = Object.assign( { - width: page.viewport().width, - height: page.viewport().height, + width: getPageViewportSize(page).width, + height: getPageViewportSize(page).height, deviceScaleFactor: scaleArg ? Number(scaleArg.split('=')[1]) || 1 : 1 }, config.viewport ); - await page.setViewport(config.viewport); + await setPageViewportSize(page, config.viewport); } await overwriteRandom(page, unrandom, log); await timeHandler.overwriteTime(page); diff --git a/lib/capture-screenshot.js b/lib/capture-screenshot.js index ea802c4..fb9a5c1 100644 --- a/lib/capture-screenshot.js +++ b/lib/capture-screenshot.js @@ -30,7 +30,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -const { getSelectorDimensions, makeFilePathConverter, makeFileDirectoryIfNeeded } = require('./utils.js'); +const { getSelectorDimensions, getPageViewportSize, makeFilePathConverter, makeFileDirectoryIfNeeded } = require('./utils.js'); module.exports = function (config) { var page = config.page; @@ -47,7 +47,7 @@ module.exports = function (config) { log('Warning: no element found for ' + config.selector); } } - var viewport = page.viewport(); + var viewport = getPageViewportSize(page); var x = config.xOffset || config.left || 0; var y = config.yOffset || config.top || 0; var right = config.right || 0; diff --git a/lib/utils.js b/lib/utils.js index 6864d86..c9cec64 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -49,6 +49,22 @@ const evaluateOnNewDocument = function (page, fn) { } }; +const getPageViewportSize = function (page) { + if (page.viewport) { + return page.viewport(); + } else if (page.viewportSize) { + return page.viewportSize(); + } +} + +const setPageViewportSize = async function (page, config) { + if (page.setViewport) { + return page.setViewport(config); + } else if (page.setViewportSize) { + return page.setViewportSize(config); + } +} + const getSelectorDimensions = async function (page, selector) { return page.evaluate(function (selector) { var el = document.querySelector(selector); @@ -125,6 +141,8 @@ const makeFileDirectoryIfNeeded = function (filepath) { module.exports = { getBrowserFrames, evaluateOnNewDocument, + getPageViewportSize, + setPageViewportSize, getSelectorDimensions, writeFile, stringArrayFind, From 3a3f4fdb1e62bb6ac894d8bb2e2f256b2e9dca52 Mon Sep 17 00:00:00 2001 From: user Date: Wed, 15 Dec 2021 08:44:51 -0800 Subject: [PATCH 05/10] switched to parameter destructuring for page.evaluate parameters --- lib/capture-canvas.js | 4 ++-- lib/immediate-canvas-handler.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/capture-canvas.js b/lib/capture-canvas.js index aa17a06..63fc40a 100644 --- a/lib/capture-canvas.js +++ b/lib/capture-canvas.js @@ -33,9 +33,9 @@ const makeCanvasCapturer = require('./make-canvas-capturer'); const canvasToBuffer = async function (page, canvasSelector, type, quality) { - var dataUrl = await page.evaluate((canvasSelector, type, quality) => + var dataUrl = await page.evaluate(({ canvasSelector, type, quality }) => document.querySelector(canvasSelector).toDataURL(type, quality) - , canvasSelector, type, quality); + , { canvasSelector, type, quality }); var data = dataUrl.slice(dataUrl.indexOf(',') + 1); return new Buffer(data, 'base64'); }; diff --git a/lib/immediate-canvas-handler.js b/lib/immediate-canvas-handler.js index 6927f28..7fd70ca 100644 --- a/lib/immediate-canvas-handler.js +++ b/lib/immediate-canvas-handler.js @@ -52,11 +52,11 @@ module.exports = function (config) { if (config.alwaysSaveCanvasData) { goToTime = async function (browserFrames, time) { // Goes to a certain time. Can't go backwards - return page.evaluate((ms, canvasSelector, type, quality) => { + return page.evaluate(({ ms, canvasSelector, type, quality }) => { window._timeweb_processUntilTime(ms); var canvasElement = document.querySelector(canvasSelector); window._timesnap_canvasData = canvasElement.toDataURL(type, quality); - }, time, canvasSelector, canvasCaptureMode, quality); + }, { ms: time, canvasSelector, type: canvasCaptureMode, quality }); }; } else { goToTime = oldGoToTime; @@ -64,14 +64,14 @@ module.exports = function (config) { const goToTimeAndAnimateForCapture = async function (browserFrames, time) { // Goes to a certain time. Can't go backwards - return page.evaluate((ms, canvasSelector, type, quality) => { + return page.evaluate(({ ms, canvasSelector, type, quality }) => { window._timeweb_processUntilTime(ms); return window._timeweb_runFramePreparers(ms, function () { window._timeweb_runAnimationFrames(); var canvasElement = document.querySelector(canvasSelector); window._timesnap_canvasData = canvasElement.toDataURL(type, quality); }); - }, time, canvasSelector, canvasCaptureMode, quality); + }, { ms: time, canvasSelector, type: canvasCaptureMode, quality }); }; var goToTimeAndAnimate; From 49ccb76795bf0339381ec2bdd6f4942f3781baaf Mon Sep 17 00:00:00 2001 From: user Date: Wed, 15 Dec 2021 23:49:09 -0800 Subject: [PATCH 06/10] moved from prefixed timeweb functions to object methods --- lib/immediate-canvas-handler.js | 12 ++++++------ lib/overwrite-time.js | 6 +++--- package.json | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/immediate-canvas-handler.js b/lib/immediate-canvas-handler.js index 7fd70ca..1564eb6 100644 --- a/lib/immediate-canvas-handler.js +++ b/lib/immediate-canvas-handler.js @@ -53,7 +53,7 @@ module.exports = function (config) { goToTime = async function (browserFrames, time) { // Goes to a certain time. Can't go backwards return page.evaluate(({ ms, canvasSelector, type, quality }) => { - window._timeweb_processUntilTime(ms); + timeweb.processUntilTime(ms); var canvasElement = document.querySelector(canvasSelector); window._timesnap_canvasData = canvasElement.toDataURL(type, quality); }, { ms: time, canvasSelector, type: canvasCaptureMode, quality }); @@ -65,9 +65,9 @@ module.exports = function (config) { const goToTimeAndAnimateForCapture = async function (browserFrames, time) { // Goes to a certain time. Can't go backwards return page.evaluate(({ ms, canvasSelector, type, quality }) => { - window._timeweb_processUntilTime(ms); - return window._timeweb_runFramePreparers(ms, function () { - window._timeweb_runAnimationFrames(); + timeweb.processUntilTime(ms); + return timeweb.runFramePreparers(ms, function () { + timeweb.runAnimationFrames(); var canvasElement = document.querySelector(canvasSelector); window._timesnap_canvasData = canvasElement.toDataURL(type, quality); }); @@ -81,8 +81,8 @@ module.exports = function (config) { goToTimeAndAnimate = async function (browserFrames, time) { // Goes to a certain time. Can't go backwards return page.evaluate(function (ms) { - window._timeweb_processUntilTime(ms); - return window._timeweb_runFramePreparers(ms, window._timeweb_runAnimationFrames); + timeweb.processUntilTime(ms); + return timeweb.runFramePreparers(ms, timeweb.runAnimationFrames); }, time); }; } diff --git a/lib/overwrite-time.js b/lib/overwrite-time.js index ad9cdaa..891247d 100644 --- a/lib/overwrite-time.js +++ b/lib/overwrite-time.js @@ -45,7 +45,7 @@ const goToTime = async function (browserFrames, time) { // Goes to a certain time. Can't go backwards return Promise.all(browserFrames.map(function (frame) { return frame.evaluate(function (ms) { - window._timeweb_processUntilTime(ms); + timeweb.processUntilTime(ms); }, time); })); }; @@ -54,8 +54,8 @@ const goToTimeAndAnimate = async function (browserFrames, time) { // Goes to a certain time. Can't go backwards return Promise.all(browserFrames.map(function (frame) { return frame.evaluate(function (ms) { - window._timeweb_processUntilTime(ms); - return window._timeweb_runFramePreparers(ms, window._timeweb_runAnimationFrames); + timeweb.processUntilTime(ms); + return timeweb.runFramePreparers(ms, timeweb.runAnimationFrames); }, time); })); }; diff --git a/package.json b/package.json index 2d755f3..f5a2fbf 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "dependencies": { "commander": "^2.11.0", "puppeteer": "^2.1.1", - "timeweb": "^0.1.1", + "timeweb": "^0.2.0", "sprintf-js": "1.1.1" }, "devDependencies": { From 5511017819ade7373c3486b1f7a96e541a66ffab Mon Sep 17 00:00:00 2001 From: user Date: Wed, 15 Dec 2021 23:55:34 -0800 Subject: [PATCH 07/10] linting --- lib/immediate-canvas-handler.js | 12 ++++++------ lib/overwrite-time.js | 6 +++--- lib/utils.js | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/immediate-canvas-handler.js b/lib/immediate-canvas-handler.js index 1564eb6..9fa5573 100644 --- a/lib/immediate-canvas-handler.js +++ b/lib/immediate-canvas-handler.js @@ -53,7 +53,7 @@ module.exports = function (config) { goToTime = async function (browserFrames, time) { // Goes to a certain time. Can't go backwards return page.evaluate(({ ms, canvasSelector, type, quality }) => { - timeweb.processUntilTime(ms); + window.timeweb.processUntilTime(ms); var canvasElement = document.querySelector(canvasSelector); window._timesnap_canvasData = canvasElement.toDataURL(type, quality); }, { ms: time, canvasSelector, type: canvasCaptureMode, quality }); @@ -65,9 +65,9 @@ module.exports = function (config) { const goToTimeAndAnimateForCapture = async function (browserFrames, time) { // Goes to a certain time. Can't go backwards return page.evaluate(({ ms, canvasSelector, type, quality }) => { - timeweb.processUntilTime(ms); - return timeweb.runFramePreparers(ms, function () { - timeweb.runAnimationFrames(); + window.timeweb.processUntilTime(ms); + return window.timeweb.runFramePreparers(ms, function () { + window.timeweb.runAnimationFrames(); var canvasElement = document.querySelector(canvasSelector); window._timesnap_canvasData = canvasElement.toDataURL(type, quality); }); @@ -81,8 +81,8 @@ module.exports = function (config) { goToTimeAndAnimate = async function (browserFrames, time) { // Goes to a certain time. Can't go backwards return page.evaluate(function (ms) { - timeweb.processUntilTime(ms); - return timeweb.runFramePreparers(ms, timeweb.runAnimationFrames); + window.timeweb.processUntilTime(ms); + return window.timeweb.runFramePreparers(ms, window.timeweb.runAnimationFrames); }, time); }; } diff --git a/lib/overwrite-time.js b/lib/overwrite-time.js index 891247d..24cf0a8 100644 --- a/lib/overwrite-time.js +++ b/lib/overwrite-time.js @@ -45,7 +45,7 @@ const goToTime = async function (browserFrames, time) { // Goes to a certain time. Can't go backwards return Promise.all(browserFrames.map(function (frame) { return frame.evaluate(function (ms) { - timeweb.processUntilTime(ms); + window.timeweb.processUntilTime(ms); }, time); })); }; @@ -54,8 +54,8 @@ const goToTimeAndAnimate = async function (browserFrames, time) { // Goes to a certain time. Can't go backwards return Promise.all(browserFrames.map(function (frame) { return frame.evaluate(function (ms) { - timeweb.processUntilTime(ms); - return timeweb.runFramePreparers(ms, timeweb.runAnimationFrames); + window.timeweb.processUntilTime(ms); + return window.timeweb.runFramePreparers(ms, window.timeweb.runAnimationFrames); }, time); })); }; diff --git a/lib/utils.js b/lib/utils.js index c9cec64..376c347 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -55,7 +55,7 @@ const getPageViewportSize = function (page) { } else if (page.viewportSize) { return page.viewportSize(); } -} +}; const setPageViewportSize = async function (page, config) { if (page.setViewport) { @@ -63,7 +63,7 @@ const setPageViewportSize = async function (page, config) { } else if (page.setViewportSize) { return page.setViewportSize(config); } -} +}; const getSelectorDimensions = async function (page, selector) { return page.evaluate(function (selector) { From 869204b28809894d0803f279742b13503ffb7281 Mon Sep 17 00:00:00 2001 From: user Date: Wed, 15 Dec 2021 23:56:16 -0800 Subject: [PATCH 08/10] update package-lock.json --- package-lock.json | 150 +++++++++++++++++++++++----------------------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/package-lock.json b/package-lock.json index 313419b..feae5c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,35 +5,35 @@ "requires": true, "dependencies": { "@babel/code-frame": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.14.5.tgz", - "integrity": "sha512-9pzDqyc6OLDaqe+zbACgFkb6fKMNG6CObKpnYXChRsvYGyEdc7CA2BaqeOM+vOtCS5ndmJicPJhKAwYRI6UfFw==", + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.0.tgz", + "integrity": "sha512-IF4EOMEV+bfYwOmNxGzSnjR2EmQod7f1UXOpZM3l4i4o4QNwzjtJAu/HxdjHq0aYBvdqMuQEY1eg0nqW9ZPORA==", "dev": true, "requires": { - "@babel/highlight": "^7.14.5" + "@babel/highlight": "^7.16.0" } }, "@babel/helper-validator-identifier": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.5.tgz", - "integrity": "sha512-5lsetuxCLilmVGyiLEfoHBRX8UCFD+1m2x3Rj97WrW3V7H3u4RWRXA4evMjImCsin2J2YT0QaVDGf+z8ondbAg==", + "version": "7.15.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz", + "integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==", "dev": true }, "@babel/highlight": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.14.5.tgz", - "integrity": "sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg==", + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.0.tgz", + "integrity": "sha512-t8MH41kUQylBtu2+4IQA3atqevA2lRgqA2wyVB/YiWmsDSuylZZuXOUy9ric30hfzauEFfdsuk/eXTRrGrfd0g==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.14.5", + "@babel/helper-validator-identifier": "^7.15.7", "chalk": "^2.0.0", "js-tokens": "^4.0.0" } }, "@types/mime-types": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@types/mime-types/-/mime-types-2.1.0.tgz", - "integrity": "sha1-nKUs2jY/aZxpRmwqbM2q2RPqenM=" + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@types/mime-types/-/mime-types-2.1.1.tgz", + "integrity": "sha512-vXOTGVSLR2jMw440moWTC7H19iUyLtP3Z1YTj7cSsubOICinjMxFeb/V57v9QdyyPGbbWolUFSSmSiRSn94tFw==" }, "acorn": { "version": "7.4.1", @@ -42,9 +42,9 @@ "dev": true }, "acorn-jsx": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", - "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true }, "agent-base": { @@ -82,9 +82,9 @@ } }, "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true }, "ansi-styles": { @@ -144,9 +144,9 @@ "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" }, "buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" }, "callsites": { "version": "3.1.0", @@ -223,9 +223,9 @@ } }, "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" }, "cross-spawn": { "version": "6.0.5", @@ -249,17 +249,17 @@ } }, "debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "requires": { "ms": "2.1.2" } }, "deep-is": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, "doctrine": { @@ -380,9 +380,9 @@ }, "dependencies": { "estraverse": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", - "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true } } @@ -397,9 +397,9 @@ }, "dependencies": { "estraverse": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", - "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true } } @@ -537,9 +537,9 @@ "dev": true }, "glob": { - "version": "7.1.7", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", - "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -658,9 +658,9 @@ } }, "chalk": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", - "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -689,12 +689,12 @@ "dev": true }, "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, "requires": { - "ansi-regex": "^5.0.0" + "ansi-regex": "^5.0.1" } }, "supports-color": { @@ -721,9 +721,9 @@ "dev": true }, "is-glob": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", - "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, "requires": { "is-extglob": "^2.1.1" @@ -785,21 +785,21 @@ "dev": true }, "mime": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz", - "integrity": "sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==" + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", + "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==" }, "mime-db": { - "version": "1.48.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.48.0.tgz", - "integrity": "sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==" + "version": "1.51.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", + "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==" }, "mime-types": { - "version": "2.1.31", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.31.tgz", - "integrity": "sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==", + "version": "2.1.34", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", + "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", "requires": { - "mime-db": "1.48.0" + "mime-db": "1.51.0" } }, "mimic-fn": { @@ -1050,9 +1050,9 @@ "dev": true }, "signal-exit": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", - "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==", + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz", + "integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==", "dev": true }, "slice-ansi": { @@ -1080,23 +1080,23 @@ "integrity": "sha1-Nr54Mgr+WAH2zqPueLblqrlA6gw=" }, "string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, "requires": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" + "strip-ansi": "^6.0.1" }, "dependencies": { "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, "requires": { - "ansi-regex": "^5.0.0" + "ansi-regex": "^5.0.1" } } } @@ -1191,9 +1191,9 @@ "dev": true }, "timeweb": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/timeweb/-/timeweb-0.1.1.tgz", - "integrity": "sha512-GP4lwJNKeEvAP30MatdV2Rigi8eASIgzI3rBGyvObU1rg3K3AgfeJSNi5qbrTEUdQYRfknACjb7OYZm16fdkTQ==" + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/timeweb/-/timeweb-0.2.0.tgz", + "integrity": "sha512-VKm6YWgQ0kKQVVsVVMZW3Fhx2ZraWk3QY9CLbPFdKkX5UpItt4KMcmZoZVzj8UVBph+3khLr0XMjlLFhB4c7FA==" }, "tmp": { "version": "0.0.33", From d30ac8367b6d046f6cd509c3e9df29bb88525335 Mon Sep 17 00:00:00 2001 From: user Date: Thu, 16 Dec 2021 00:13:45 -0800 Subject: [PATCH 09/10] fix for unrandomize not initializing correctly Adds support for passing an argument to evaluateOnNewDocument. Note that it seems that playwright doesn't support multiple arguments with `page.addInitScript`, so multiple arguments should not be used for these types of functions. --- lib/utils.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 376c347..5544cfe 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -41,11 +41,19 @@ const getBrowserFrames = function (frame) { return [frame].concat(...frame.childFrames().map(getBrowserFrames)); }; -const evaluateOnNewDocument = function (page, fn) { +const evaluateOnNewDocument = function (page, fn, arg) { if (page.evaluateOnNewDocument) { - page.evaluateOnNewDocument(fn); + if (arg !== undefined) { + page.evaluateOnNewDocument(fn, arg); + } else { + page.evaluateOnNewDocument(fn); + } } else if (page.addInitScript) { - page.addInitScript(fn); + if (arg !== undefined) { + page.addInitScript(fn, arg); + } else { + page.addInitScript(fn); + } } }; From 657d8d255ed954af17ba5fbe30981a4347c74eba Mon Sep 17 00:00:00 2001 From: user Date: Thu, 16 Dec 2021 00:33:49 -0800 Subject: [PATCH 10/10] version bump to v0.3.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index feae5c7..a4c0970 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "timesnap", - "version": "0.3.1-prerelease", + "version": "0.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index f5a2fbf..3f0221d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "timesnap", - "version": "0.3.1-prerelease", + "version": "0.3.1", "description": "Take screenshots of web pages at smooth intervals", "repository": { "type": "git",