https://github.com/regseb/playwright-ghost
Playwright overlay with plugins.
https://github.com/regseb/playwright-ghost
ghost headless playwright polyfill
Last synced: 5 months ago
JSON representation
Playwright overlay with plugins.
- Host: GitHub
- URL: https://github.com/regseb/playwright-ghost
- Owner: regseb
- License: mit
- Created: 2022-04-21T19:15:01.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-30T20:43:23.000Z (9 months ago)
- Last Synced: 2025-01-31T00:32:54.422Z (5 months ago)
- Topics: ghost, headless, playwright, polyfill
- Language: JavaScript
- Homepage:
- Size: 1.67 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# Playwright-ghost
[![npm][img-npm]][link-npm] [![build][img-build]][link-build]
[![coverage][img-coverage]][link-coverage] [![semver][img-semver]][link-semver]> [!NOTE]
>
> This project is not officially commissioned or supported by Microsoft and
> Playwright.Playwright-ghost is an overlay on [Playwright](https://playwright.dev/), adding
plugins to conceal the differences between a browser used by a human being and a
[headless browser](https://en.wikipedia.org/wiki/Headless_browser) controlled by
a program.The Playwright-ghost API is identical to that of Playwright, except for the
addition of the `plugins` option to the
[`browserType.launch([options])`](https://playwright.dev/docs/api/class-browsertype#browser-type-launch)
and
[`browserType.launchPersistentContext(userDataDir, [options])`](https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context)
methods.The `plugins` property is an array containing the plugins to be added.
## Install
[`playwright-ghost`](https://www.npmjs.com/package/playwright-ghost) doesn't
provide [`playwright`](https://www.npmjs.com/package/playwright), so you need to
add it to your dependencies.```shell
npm install playwright playwright-ghost
````playwright-ghost` can also be used with
[`rebrowser-playwright`](https://www.npmjs.com/package/rebrowser-playwright).```shell
npm install rebrowser-playwright playwright-ghost
```## Use
Here's an example with the recommended plugins.
```javascript
import { chromium, plugins } from "playwright-ghost";
// Or to use rebrowser-playwright:
// import { chromium, plugins } from "playwright-ghost/rebrowser";const browser = await chromium.launch({
plugins: plugins.recommended(),
});
const context = await browser.newContext();
const page = await context.newPage();await page.goto("https://example.com/");
const title = await page.locator("h1").textContent();
console.log(title);await context.close();
await browser.close();
```In this other example, three plugins are added:
- `polyfill.headless` has no options;
- `polyfill.screen` sets other values for screen size;
- `utils.adblocker` uses default options.```javascript
import { chromium, plugins } from "playwright-ghost";const browser = await chromium.launch({
plugins: [
plugins.polyfill.headless(),
plugins.polyfill.screen({ width: 2560, height: 1440 }),
plugins.utils.adblocker(),
],
});
// ...
```And for this example, the recommended plugins and the `utils.locale` plugin are
added.```javascript
import { chromium, plugins } from "playwright-ghost";const browser = await chromium.launch({
plugins: [...plugins.recommended(), plugins.utils.locale()],
});
// ...
```## Plugins
β is in `recommended` / βοΈ has options / π¦ requires dependency
NameDescription
β
polyfill.automation
Disable--enable-automation
in Chromium.
β
polyfill.headless
Correct many differences in Javascript APIs between the headful and
headless versions of Chromium.
β βοΈ
polyfill.screen
Set a realistic value for screen size: 1920x1080.
βοΈ
polyfill.userAgent
Change the browser's user agent.
β βοΈ
polyfill.viewport
Vary viewport size with random values between 1000x500 and 1800x800.
β
polyfill.webdriver
Setnavigator.webdriver
tofalse
.
polyfill.webGL
Modify WebGL parameter values.
β βοΈ
humanize.dialog
Close<dialog>
within a humanly possible time (between
1 and 5 seconds).
βοΈ π¦
utils.adblocker
Add Ghostery adblocker.
utils.debug
Display messages from the browser console in the program console.
utils.locale
Use the locally installed browser.
## Anti-bots
Chromiumα΅
Firefoxα΅
Brotector
βΒΉ 0.98 (UA_Override & Input.cordinatesLeak)
β 1.00 (navigator.webdriver & PWinitScript)
BrowserScan
β
β WebDriver
Chromedriver Detector
β
β
CreepJS
β B-
β F+
Datadome
β
β
Deviceandbrowserinfo
β GPU
β Webdriver
Device Info
β
β
FingerprintJS
β
β Automation Tool
HeadlessDetectJS
β
β 0.2
infosimples
β
β Webdriver & Plugins
Chrome Headless Detection (Intoli)
β
β WebDriver & Plugins
rebrowser-bot-detector
β pwInitScripts
β navigatorWebdriver
Antibot (Sannysoft)
β
β Webdriver & Plugins
Cloudflare turnstile demo
β
β
α΅ Chromium with `rebrowser-playwright`, recommended plugins and the
`polyfill.userAgent` plugin (to remove _Headless_).\
α΅ Firefox with `playwright` and recommended plugins.\
ΒΉ Without [_popupCrash_](https://github.com/kaliiiiiiiiii/brotector#popupcrash).[img-npm]:
https://img.shields.io/npm/dm/playwright-ghost?label=npm&logo=npm&logoColor=whitesmoke
[img-build]:
https://img.shields.io/github/actions/workflow/status/regseb/playwright-ghost/ci.yml?branch=main&logo=github&logoColor=whitesmoke
[img-coverage]:
https://img.shields.io/endpoint?label=coverage&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fregseb%2Fplaywright-ghost%2Fmain
[img-semver]:
https://img.shields.io/badge/semver-2.0.0-blue?logo=semver&logoColor=whitesmoke
[link-npm]: https://www.npmjs.com/package/playwright-ghost
[link-build]:
https://github.com/regseb/playwright-ghost/actions/workflows/ci.yml?query=branch%3Amain
[link-coverage]:
https://dashboard.stryker-mutator.io/reports/github.com/regseb/playwright-ghost/main
[link-semver]: https://semver.org/spec/v2.0.0.html "Semantic Versioning 2.0.0"