Add config for setting custom Chromium path
Also update SETUP/README with instructions
This commit is contained in:
parent
70061a560f
commit
4e21113940
20
SETUP.md
20
SETUP.md
|
@ -9,18 +9,26 @@
|
|||
# Initial setup
|
||||
## Puppeteer module
|
||||
1. Download a .crx or .zip file of the [LINE Chrome extension](https://chrome.google.com/webstore/detail/line/ophjlpahpchlmihnnnihgmmeilfjmjjc) (current version: 2.4.5)
|
||||
* The recommended way of doing this is with the [CRX Extractor/Downloader](https://chrome.google.com/webstore/detail/crx-extractordownloader/ajkhmmldknmfjnmeedkbkkojgobmljda) extension for Chrome/Chromium. Simply install that extension in a Chrome/Chromium instance of your choice, then navigate to the Web Store page for the LINE extension, click the "CRX" button in the toolbar, and select "Download as ZIP"
|
||||
1. Extract the downloaded .crx file to `puppet/extension_files`
|
||||
* The recommended way of doing this is with the [CRX Extractor/Downloader](https://chrome.google.com/webstore/detail/crx-extractordownloader/ajkhmmldknmfjnmeedkbkkojgobmljda) extension for Chrome/Chromium:
|
||||
1. Install that extension in a Chrome/Chromium instance of your choice
|
||||
2. Navigate to the Web Store page for the LINE extension
|
||||
3. Click the "CRX" button in the browser toolbar
|
||||
4. Select "Download as CRX" or "Download as ZIP"
|
||||
1. Extract the downloaded .crx/.zip file to `puppet/extension_files`
|
||||
* This can be done with `unzip <*.crx|*.zip> -d puppet/extension_files`, or with a GUI tool like GNOME File Roller
|
||||
1. `cd` to the `puppet` directory and run `yarn --production`
|
||||
1. Run `node prep_helper.js` to open the version of Chrome downloaded by Puppeteer, and click on the LINE icon next to the URL bar
|
||||
1. Copy `puppet/example-config.json` to `puppet/config.json`
|
||||
1. If your system's CPU architecture is not x86\_64, the version of Chromium bundled with Puppeteer will not work, and the following steps are required:
|
||||
1. Install Chrome/Chromium from your distribution's package manager
|
||||
1. Set `executable_path` in `puppet/config.json` to the path to the installed Chrome/Chromium binary
|
||||
1. Run `node prep_helper.js` to open Chrome/Chromium with the downloaded LINE extension enabled, and click on the LINE icon next to the URL bar
|
||||
1. Once the LINE popup appears, press F12 to show DevTools, which will reveal the LINE extension's UUID
|
||||
1. Copy `puppet/example-config.json` to `puppet/config.json`, and set some important settings:
|
||||
1. Edit `puppet/config.json` with some important settings:
|
||||
* set `"url"` to the UUID found in the previous step
|
||||
* set the `"listen"` settings to the socket to use for communication with the bridge (see [puppet/README.md](puppet/README.md) for details)
|
||||
|
||||
## Bridge
|
||||
1. `cd` to the project root directory and create a Python virtual environment with `python -m venv .venv`, and enter it with `source .venv/bin/activate`
|
||||
1. `cd` to the project root directory and create a Python virtual environment with `python3 -m venv .venv`, and enter it with `source .venv/bin/activate`
|
||||
1. Install Python requirements:
|
||||
* `pip install -Ur requirements.txt` for base functionality
|
||||
* `pip install -Ur optional_requirements.txt` for [end-to-bridge](https://docs.mau.fi/bridges/general/end-to-bridge-encryption.html) encryption and metrics
|
||||
|
@ -34,7 +42,7 @@
|
|||
1. Start a chat with the bot and follow the instructions
|
||||
|
||||
# Running the Puppeteer module headless
|
||||
Puppeteer cannot be run in headless mode when using Chromium with extensions (including the LINE extension).
|
||||
Puppeteer cannot be run in headless mode when using Chrome/Chromium with extensions (including the LINE extension).
|
||||
|
||||
As a workaround, it may be run in a background X server. This allows running the Puppeteer module on a GUI-less server.
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@ If `type` is `unix`, `path` is the path where to create the socket.
|
|||
|
||||
If `type` is `tcp`, `port` and `host` are the host/port where to listen.
|
||||
|
||||
### Executable path
|
||||
The `executable_path` specifies the path to the Chromium binary for Puppeteer to use. Leaving this setting blank will use the x86_64 Chromium installation bundled with Puppeteer. For other architectures, it is necessary to install a compatible version of Chromium (ideally via your distribution's package manager), and to set `executable_path` to the path of its binary (typically `/usr/bin/chromium`).
|
||||
|
||||
### Profile directory
|
||||
The `profile_dir` specifies which directory to put Chromium user data directories.
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"type": "unix",
|
||||
"path": "/var/run/matrix-puppeteer-line/puppet.sock"
|
||||
},
|
||||
"executable_path": "",
|
||||
"profile_dir": "./profiles",
|
||||
"url": "chrome-extension://<extension-uuid>/index.html",
|
||||
"extension_dir": "./extension_files",
|
||||
|
|
|
@ -1,13 +1,45 @@
|
|||
// matrix-puppeteer-line - A very hacky Matrix-LINE bridge based on running LINE's Chrome extension in Puppeteer
|
||||
// Copyright (C) 2020-2021 Tulir Asokan, Andrew Ferrazzutti
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import puppeteer from "puppeteer"
|
||||
import fs from "fs"
|
||||
|
||||
import arg from "arg"
|
||||
|
||||
const args = arg({
|
||||
"--config": String,
|
||||
"--browser": String,
|
||||
"-c": "--config",
|
||||
"-b": "--browser",
|
||||
})
|
||||
|
||||
const configPath = args["--config"] || "config.json"
|
||||
|
||||
console.log("[Main] Reading config from", configPath)
|
||||
const config = JSON.parse(fs.readFileSync(configPath).toString())
|
||||
const extensionDir = config.extension_dir || "extension_files"
|
||||
const executablePath = args["--browser"] || config.executable_path;
|
||||
|
||||
(async () =>
|
||||
{
|
||||
const pathToExtension = "extension_files"
|
||||
const browser = await puppeteer.launch({
|
||||
await puppeteer.launch({
|
||||
executablePath: executablePath,
|
||||
headless: false,
|
||||
args: [
|
||||
`--disable-extensions-except=${pathToExtension}`,
|
||||
`--load-extension=${pathToExtension}`
|
||||
`--disable-extensions-except=${extensionDir}`,
|
||||
`--load-extension=${extensionDir}`
|
||||
],
|
||||
timeout: 0,
|
||||
})
|
||||
|
|
|
@ -30,11 +30,11 @@ const args = arg({
|
|||
})
|
||||
|
||||
const configPath = args["--config"] || "config.json"
|
||||
MessagesPuppeteer.executablePath = args["--browser"] || MessagesPuppeteer.executablePath
|
||||
MessagesPuppeteer.noSandbox = args["--no-sandbox"]
|
||||
|
||||
console.log("[Main] Reading config from", configPath)
|
||||
const config = JSON.parse(fs.readFileSync(configPath).toString())
|
||||
MessagesPuppeteer.executablePath = args["--browser"] || config.executable_path || MessagesPuppeteer.executablePath
|
||||
MessagesPuppeteer.noSandbox = args["--no-sandbox"] || MessagesPuppeteer.noSandbox
|
||||
MessagesPuppeteer.profileDir = config.profile_dir || MessagesPuppeteer.profileDir
|
||||
MessagesPuppeteer.devtools = config.devtools || false
|
||||
MessagesPuppeteer.url = config.url
|
||||
|
|
Loading…
Reference in New Issue