I'm trying to use puppeteer extra stealth plugin with the spatie Browsershot. This pull seems to explain the steps but I'm unable to reproduce: https://github.com/spatie/browsershot/pull/399
It's asking to put the following in a libs/browserhot.js file but I'm not sure where to put this file:
libs/browsershot.js
const path = require("path");
const puppeteer = require("puppeteer-extra");
const puppeteerAdblock = require("puppeteer-extra-plugin-adblocker");
const puppeteerStealth = require("puppeteer-extra-plugin-stealth");
const dir = path.dirname(__dirname);
const script = `${dir}/vendor/spatie/browsershot/bin/browser.js`;
const browser = require(script);
puppeteer.use(puppeteerAdblock({blockTrackers: true}));
puppeteer.use(puppeteerStealth());
browser.callChrome(puppeteer);
Then call it via setBinPath() like this:
$bs = Browsershot::url("index.html");
$bs -> addChromiumArguments(["no-sandbox"]);
$bs -> setBinPath(dirname(__DIR__) . "/libs/browsershot.js");