From 3db14315c492206260f10c7201724a55c3c169da Mon Sep 17 00:00:00 2001 From: macbre Date: Sun, 10 Mar 2024 22:49:13 +0000 Subject: [PATCH] page.waitForTimeout is gone, just use promisified setTimeout from Node.js https://pptr.dev/api/puppeteer.page.waitforselector --- extensions/postLoadDelay/postLoadDelay.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions/postLoadDelay/postLoadDelay.js b/extensions/postLoadDelay/postLoadDelay.js index a30c6e232..123c6927e 100644 --- a/extensions/postLoadDelay/postLoadDelay.js +++ b/extensions/postLoadDelay/postLoadDelay.js @@ -3,6 +3,8 @@ */ "use strict"; +const { setTimeout } = require("timers/promises"); + module.exports = function (phantomas) { // e.g. --post-load-delay 5 var delay = parseInt(phantomas.getParam("post-load-delay"), 10); @@ -14,9 +16,9 @@ module.exports = function (phantomas) { // https://github.com/GoogleChrome/puppeteer/blob/v1.11.0/docs/api.md#framewaitforselectororfunctionortimeout-options-args phantomas.log("Will wait %d second(s) after load", delay); - phantomas.on("beforeClose", (page) => { + phantomas.on("beforeClose", async (page) => { phantomas.log("Sleeping for %d seconds", delay); - return page.waitForTimeout(delay * 1000); + return setTimeout(delay * 1000); }); };