Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #46 from Flowko/44-would-it-be-possible-to-auto-in…
Browse files Browse the repository at this point in the history
…stall-plugins-like-ublock-origin-into-the-website-shot-browser

feat: added Environment variable for blocking ads
  • Loading branch information
Flowko authored Nov 14, 2022
2 parents 45196f9 + 00c45b2 commit ac8ded4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ ENV PASSWORD_PROTECT 0
ENV PASSWORD null
ENV RUNNING_DOCKER 1
ENV USER_AGENT "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
ENV BLOCK_ADS 1

CMD [ "yarn", "start" ]
5 changes: 3 additions & 2 deletions server-middleware/capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,11 @@ const internalCaptureWebsite = async (input, options) => {
let browser;
let page;
try {
browser = options._browser || (await puppeteer.launch(launchOptions));
browser = await puppeteer.launch(launchOptions);

page = await browser.newPage();

if (options.blockAds) {
if (options.blockAds || process.env.BLOCK_ADS == "1") {
const blocker = await PuppeteerBlocker.fromPrebuiltFull(fetch, {
path: "engine.bin",
read: fs.readFile,
Expand Down

0 comments on commit ac8ded4

Please sign in to comment.