-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathREADME.md
More file actions
96 lines (74 loc) · 3.25 KB
/
README.md
File metadata and controls
96 lines (74 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<h1 align="center">
<img src="assets/logo.png" alt="Playwright-Stealth for JVM" width="620"/>
</h1>


Playwright-Stealth for JVM is a Kotlin-based library that helps bypass bot detection mechanisms by applying various evasions to Playwright’s BrowserContext and/or Pages. Designed for seamless integration with Java, Kotlin, and Groovy, this library provides an intuitive API to enhance browser automation stealthiness.
JVM Porting of https://github.com/AtuboDad/playwright_stealth
## Features
- ✅ Stealth Enhancements – Modify navigator properties, WebGL fingerprints, and more.
- ✅ JVM Compatibility – Usable in any JVM-based project.
- ✅ Easy API – Simple integration methods.
- ✅ Customizable Configurations – Enable or disable specific evasions as needed.
## Installation
Playwright-Stealth for JVM is distributed via [Maven Central](https://central.sonatype.com/artifact/io.github.kihdev/playwright-stealth-4j). You can add it to your project using Gradle or Maven.
Add the dependency to your `build.gradle.kts`:
```kotlin
dependencies {
implementation("io.github.kihdev:playwright-stealth-4j:1.1.2")
}
```
or to your `pom.xml`:
```xml
<dependency>
<groupId>io.github.kihdev</groupId>
<artifactId>playwright-stealth-4j</artifactId>
<version>1.1.2</version>
</dependency>
```
## Usage
From Kotlin, handy extension functions `stealth()` are provided to `BrowserContext` and `Page` classes.
```kotlin
import com.microsoft.playwright.*
import io.github.kihdev.playwright.stealth4j.Stealth4j
fun stealth() {
Playwright.create().use { playwright ->
val chromium = playwright.chromium()
chromium.launch().use { browser ->
val context = browser.newContext().stealth()
val page = context.newPage()
page.navigate("https://bot.sannysoft.com/")
page.screenshot(
Page.ScreenshotOptions()
.setPath(Paths.get("build/tmp/screenshots/stealth.png"))
.setFullPage(true)
)
}
}
}
```
From Java, you can use the `Stealth4j` class to apply stealth features to your `BrowserContext` or `Page`.
```java
import com.microsoft.playwright.*;
import io.github.kihdev.playwright.stealth4j.Stealth4j;
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch();
var stealthContext = Stealth4j.newStealthContext(browser);
Page page = stealthContext.newPage();
page.navigate("https://bot.sannysoft.com/");
page.screenshot(
new Page.ScreenshotOptions()
.setPath(Paths.get("build/tmp/screenshots/stealth.png"))
.setFullPage(true)
);
}
}
```
## Test Results
From [bot.sannysoft.com](https://bot.sannysoft.com/)
| Headless | With stealth |
|--------------|--------------|
|  |  |
## Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.