From 1932bca139a797f8e0245334a06a1a370ccbb9cf Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Thu, 14 Oct 2021 23:55:38 -0400 Subject: [PATCH] Log to puppeteer from content script --- puppet/src/contentscript.js | 10 ++++++++++ puppet/src/puppet.js | 2 ++ 2 files changed, 12 insertions(+) diff --git a/puppet/src/contentscript.js b/puppet/src/contentscript.js index e6eba83..34a31ab 100644 --- a/puppet/src/contentscript.js +++ b/puppet/src/contentscript.js @@ -22,6 +22,16 @@ * @return {Promise} */ window.__chronoParseDate = function (text, ref, option) {} +/** + * @param {...string} text - The objects to log. + * @return {Promise} + */ +window.__mautrixLog = function (...text) {} +/** + * @param {...string} text - The objects to log. + * @return {Promise} + */ +window.__mautrixError = function (...text) {} /** * @param {ChatListInfo[]} changes - The chats that changed. * @return {Promise} diff --git a/puppet/src/puppet.js b/puppet/src/puppet.js index f202448..a8c583c 100644 --- a/puppet/src/puppet.js +++ b/puppet/src/puppet.js @@ -126,6 +126,8 @@ export default class MessagesPuppeteer { await this._preparePage(true) this.log("Exposing functions") + await this.page.exposeFunction("__mautrixLog", this.log.bind(this)) + await this.page.exposeFunction("__mautrixError", this.error.bind(this)) await this.page.exposeFunction("__mautrixReceiveQR", this._receiveQRChange.bind(this)) await this.page.exposeFunction("__mautrixSendEmailCredentials", this._sendEmailCredentials.bind(this)) await this.page.exposeFunction("__mautrixReceivePIN", this._receivePIN.bind(this))