From 38976558f597f2ab1837d67621cccb24e29f39e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Ara=C3=BAjo=20Paes?= <38794747+ricardoapaes@users.noreply.github.com> Date: Tue, 1 Jun 2021 23:05:44 -0300 Subject: [PATCH] feat(dev): add argument bypassCSP to use in pupperter (#635) --- src/Client.js | 5 +++++ src/util/Constants.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Client.js b/src/Client.js index 580af22..3116953 100644 --- a/src/Client.js +++ b/src/Client.js @@ -30,6 +30,7 @@ const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification * @param {number} options.takeoverTimeoutMs - How much time to wait before taking over the session * @param {string} options.userAgent - User agent to use in puppeteer * @param {string} options.ffmpegPath - Ffmpeg path to use when formating videos to webp while sending stickers + * @param {boolean} options.bypassCSP - Sets bypassing of page's Content-Security-Policy. * * @fires Client#qr * @fires Client#authenticated @@ -82,6 +83,10 @@ class Client extends EventEmitter { }, this.options.session); } + if(this.options.bypassCSP) { + await page.setBypassCSP(true); + } + await page.goto(WhatsWebURL, { waitUntil: 'load', timeout: 0, diff --git a/src/util/Constants.js b/src/util/Constants.js index 3fb851b..1e32dc0 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -14,7 +14,8 @@ exports.DefaultOptions = { takeoverOnConflict: false, takeoverTimeoutMs: 0, userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36', - ffmpegPath: 'ffmpeg' + ffmpegPath: 'ffmpeg', + bypassCSP: false }; /**