diff --git a/puppet/example-config.json b/puppet/example-config.json index e5d7bae..807bfca 100644 --- a/puppet/example-config.json +++ b/puppet/example-config.json @@ -4,6 +4,5 @@ "path": "/var/run/mautrix-line/puppet.sock" }, "profile_dir": "./profiles", - "disable_debug": true, - "url": "https://messages.google.com/web/" + "url": "chrome-extension:///index.html" } diff --git a/puppet/src/main.js b/puppet/src/main.js index d4f6634..82384a9 100644 --- a/puppet/src/main.js +++ b/puppet/src/main.js @@ -37,7 +37,7 @@ console.log("[Main] Reading config from", configPath) const config = JSON.parse(fs.readFileSync(configPath).toString()) MessagesPuppeteer.profileDir = config.profile_dir || MessagesPuppeteer.profileDir MessagesPuppeteer.disableDebug = !!config.disable_debug -MessagesPuppeteer.url = config.url || MessagesPuppeteer.url +MessagesPuppeteer.url = config.url const api = new PuppetAPI(config.listen) diff --git a/puppet/src/puppet.js b/puppet/src/puppet.js index 15226e2..26627f9 100644 --- a/puppet/src/puppet.js +++ b/puppet/src/puppet.js @@ -28,7 +28,7 @@ export default class MessagesPuppeteer { static disableDebug = false static noSandbox = false static viewport = { width: 1920, height: 1080 } - static url = "https://messages.google.com/web/" + static url = undefined /** * @@ -63,11 +63,18 @@ export default class MessagesPuppeteer { */ async start(debug = false) { this.log("Launching browser") + + const pathToExtension = require('path').join(__dirname, 'extension_files'); + const extensionArgs = [ + `--disable-extensions-except=${pathToExtension}`, + `--load-extension=${pathToExtension}` + ]; + this.browser = await puppeteer.launch({ executablePath: MessagesPuppeteer.executablePath, userDataDir: this.profilePath, - args: MessagesPuppeteer.noSandbox ? ["--no-sandbox"] : undefined, - headless: MessagesPuppeteer.disableDebug || !debug, + args: MessagesPuppeteer.noSandbox ? extensionArgs.concat("--no-sandbox") : extensionArgs, + headless: false, // Needed to load extensions defaultViewport: MessagesPuppeteer.viewport, }) this.log("Opening new tab")