人形遣い - Firefoxの拡張機能の実装
人形遣い- Firefoxはすでに多くの人々がしかし、開発作業の中に入れ、そしてクロームで一貫性のない拡張APIを開くためにクロムを起動している、我々は簡単にパラメータがプラグインを開くことができます設定することができますが、Firefoxで、我々は、使用したいweb-ext
Firefoxと使用を開始します接続するために接続します。
人形遣い-のFirefoxの現在の先端のツリーステータスがで空くれisPuppeteerFirefoxReady?
アドオン
Firefoxのアドオンは、そのインストールの歳差運動が異なっているため、Chromeの拡張機能とは異なります。
Firefoxはアドオン使用してインストールすることができるウェブ-EXT Firefoxのバイナリを実行し、人形遣いの使用して接続することができるライブラリconnect
APIを。
const webExt = require('web-ext').default;
const pptrFirefox = require('puppeteer-firefox');
const getPort = require('get-port');
(async () => {
const CDPPort = await getPort();
await webExt.cmd.run(
{
sourceDir: 'path-to-add-on',
firefox: pptrFirefox.executablePath(),
args: [`-juggler=${CDPPort}`]
},
{
// These are non CLI related options for each function.
// You need to specify this one so that your NodeJS application
// can continue running after web-ext is finished.
shouldExitProgram: false
}
);
const browser = await pptrFirefox.connect({
browserWSEndpoint: `ws://127.0.0.1:${CDPPort}`
});
})();
package.json
例
{
"dependencies": {
...
"get-port": "^4.2.0",
"web-ext": "^3.1.0",
"puppeteer-firefox": "^0.5.0"
...
},
}