Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Headless puppeteer with additional plugins and settings

License

NotificationsYou must be signed in to change notification settings

chickencoding123/puppeteer-enhanced-browser

Repository files navigation

Headless puppeteer with additional plugins and settings

npmLicense

Features

  • Ad block and stealth plugins
  • Add or remove plugins
  • Automatic tiles for page snapshots
  • A few puppeteer glitch workarounds

How to use

npm i puppeteer-enhanced-browser# oryarn add puppeteer-enhanced-browser
constbrowser=require('puppeteer-enhanced-browser')// orimport{GoToPage,GetBrowser,CloseBrowser}from'puppeteer-enhanced-browser'

You can optionally request evaluation results, page content or snapshots.

// thenGoToPage('https://example.com',{content:true,/* HTML of the page */snapshots:true,/* or options for tile size etc... */,evaluate:function(){/* results.evaluate will equal the body width */returndocument.body.clientWidth}}).then((results)=>{// TODO})// orconst{ snapshots, evaluate}=awaitGoToPage('https://example.com',{content:true,/* HTML of the page */snapshots:true,/* or options for tile size etc... */,evaluate:function(){/* evaluate will equal the body width */returndocument.body.clientWidth}})

Evalulation with args passed between your code context and puppeteer's browser context

const{ evaluate}=awaitGoToPage('https://example.com',{evaluate:function(a,b){/* evaluate will equal the body width */returna+b},evaluateArgs:[1,2]})

Adjusting the tile size and/or snapshot limits

const{ evaluate, snapshots}=awaitGoToPage('https://example.com',{snapshots:{tileSize:1000,/* 1000px wide snapshots */limit:5/* do not snapshot the entire page, but only 5 snapshots. Depending on the tileSize this will return snapshots from all of or a portion of the page */}});

Script and/or style injections

const{ evaluate}=awaitGoToPage('https://example.com',{style:`body { width: 1000px !important; }`,script:`window.myObj = { function message () { return 'Hello World!'; } }`evaluate:()=>{returnwindow.myObj.message();}});console.log(evaluate)

Add/Remove plugins

import{PuppeteerExtraPlugin}from'puppeteer-extra-plugin'import{AddPlugin,RemovePlugin}from'puppeteer-enhanced-browser'classTestPluginextendsPuppeteerExtraPlugin{constructor(opts={}){super(opts)}getname(){return'testplugin'}}// add a new pluginAddPlugin(newTestPlugin())// remove the default adblock pluginRemovePlugin('adblock')

Modify puppeteer launch options

You can setup launch option before callingGoToPage,GetBrowser or by callingCloseBrowser and then executing one of the former functions.

importPuppeteerLaunchOptionsfrom'puppeteer-enhanced-browser'PuppeteerLaunchOptions.dumpio=true

About

Headless puppeteer with additional plugins and settings

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp