Note: For devices running Android API level 30 or lower, it is recommended to specify a custom
userAgent
in theWebView
settings to prevent being blocked by outdated browser warnings.
Cloudflare-Bypass is an Android library designed to seamlessly bypass Cloudflare's anti-bot protection using a custom WebViewClient
. This library allows developers to load websites protected by Cloudflare's challenge without needing manual user intervention.
- Custom
WebViewClient
for Cloudflare bypass. - Automatic handling of Cloudflare's anti-bot checks.
- Easy integration into any Android project with minimal setup.
- Supports bypass for sites using Cloudflare protection.
- Minimum SDK: 21 (Android 5.0 Lollipop)
- Compile SDK: 34
- Target SDK: 34
- Language: Kotlin
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation("com.github.darkryh:Cloudflare-Bypass:$version")
}
@Composable
fun ComposableWebView(modifier: Modifier = Modifier) {
AndroidView(
modifier = modifier.fillMaxSize(),
factory = { context ->
WebView(context).apply {
webViewClient = BypassClient()
}
}
)
}
Options available to the client. The other settings remain unchanged.
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
CloudFlareByPassTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
AndroidView(
modifier = Modifier
.padding(innerPadding)
.fillMaxSize(),
factory = { context ->
WebView(context).apply {
/**do configuration **/
webViewClient = object : BypassClient() {
override fun onPageStartedPassed(
view: WebView?,
url: String?,
favicon: Bitmap?
) {
println("onPageStartedPassed")
super.onPageStartedPassed(view, url, favicon)
}
override fun onPageFinishedByPassed(view: WebView?, url: String?) {
super.onPageFinishedByPassed(view, url)
Toast.makeText(context, "Bypass", Toast.LENGTH_SHORT).show()
}
}
loadUrl("Your target site")
}
}
)
}
}
}
}
}
If you want to help or collaborate, feel free to contact me on X (Twitter) account @Darkryh or just make a pull request.