<h1 align="center">
re-cdp-patches
</h1>
<p align="center">
<a href="https://github.com/imamousenotacat/re-cdp-patches/blob/main/LICENSE">
<img src="https://img.shields.io/badge/License-GNU%20GPL-green">
</a>
<a href="https://python.org/">
<img src="https://img.shields.io/badge/python-3.9‐3.12-blue">
</a>
<a href="https://pypi.org/project/re-cdp-patches/">
<img alt="PyPI" src="https://img.shields.io/pypi/v/re-cdp-patches.svg?color=1182C3">
</a>
<br>
<a href="https://github.com/imamousenotacat/re-cdp-patches/actions">
<img src="https://github.com/imamousenotacat/re-cdp-patches/actions/workflows/ci.yml/badge.svg">
</a>
<a href="http://mypy-lang.org">
<img src="http://www.mypy-lang.org/static/mypy_badge.svg">
</a>
<a href="https://github.com/PyCQA/flake8">
<img src="https://img.shields.io/badge/code%20quality-Flake8-green.svg">
</a>
<a href="https://github.com/ambv/black">
<img src="https://img.shields.io/badge/code%20style-black-black.svg">
</a>
<a href="https://github.com/PyCQA/isort">
<img src="https://img.shields.io/badge/imports-isort-yellow.svg">
</a>
</p>
This is a pruned version of [CDP Patches](https://github.com/Kaliiiiiiiiii-Vinyzu/CDP-Patches) that only works with Playwright and [Patchright](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright), and that I'm using to enhance the stealthiness of my [Cloudflare-defeating browser-use version](https://github.com/imamousenotacat/re-browser-use).
By using real OS-level events when clicking elements, I can bypass certain additional limitations that occur when using a VPN.
## Install it from PyPI
```bash
pip install re-cdp-patches
```
<details>
<summary>Or for Full Linting</summary>
#### (Includes: playwright, re-patchright)
```bash
pip install re-cdp-patches[automation_linting]
```
</details>
---
# Leak Patches
<details>
<summary>Input Package</summary>
### Concept: Input Domain Leaks
Bypass CDP Leaks in [Input](https://chromedevtools.github.io/devtools-protocol/tot/Input/) domains
[](https://github.com/kaliiiiiiiiii/brotector)
For an interaction event `e`, the page coordinates won't ever equal the screen coordinates, unless Chrome is in fullscreen.
However, all `CDP` input commands just set it the same by default (see [crbug#1477537](https://bugs.chromium.org/p/chromium/issues/detail?id=1477537)).
```js
var is_bot = (e.pageY == e.screenY && e.pageX == e.screenX)
if (is_bot && 1 >= outerHeight - innerHeight){ // fullscreen
is_bot = false
}
```
Furthermore, CDP can't dispatch `CoalescedEvent`'s ([demo](https://omwnk.codesandbox.io/)).
As we don't want to patch Chromium itsself, let's just dispatch this event at OS-level!
---
## Usage
```py
from cdp_patches.input import SyncInput
sync_input = SyncInput(pid=pid)
# Or
sync_input = SyncInput(browser=browser)
# Dispatch Inputs
sync_input.click("left", 100, 100) # Left click at (100, 100)
sync_input.double_click("left", 100, 100) # Left double-click at (100, 100)
sync_input.down("left", 100, 100) # Left mouse button down at (100, 100)
sync_input.up("left", 100, 100) # Left mouse button up at (100, 100)
sync_input.move(100, 100) # Move mouse to (100, 100)
sync_input.scroll("down", 10) # Scroll down by 10 lines
sync_input.type("Hello World!") # Type "Hello World!"
```
## Async Usage
```py
import asyncio
from cdp_patches.input import AsyncInput
async def main():
async_input = await AsyncInput(pid=pid)
# Or
async_input = await AsyncInput(browser=browser)
# Dispatch Inputs
await async_input.click("left", 100, 100) # Left click at (100, 100)
await async_input.double_click("left", 100, 100) # Left double-click at (100, 100)
await async_input.down("left", 100, 100) # Left mouse button down at (100, 100)
await async_input.up("left", 100, 100) # Left mouse button up at (100, 100)
await async_input.move(100, 100) # Move mouse to (100, 100)
await async_input.scroll("down", 10) # Scroll down by 10 lines
await async_input.type("Hello World!") # Type "Hello World!"
if __name__ == '__main__':
asyncio.run(main())
```
### TODO
- [ ] Improve mouse movement timings.
- [ ] Implement extensive testing.
#### Owner: [Vinyzu](https://github.com/Vinyzu/)
#### Co-Maintainer: [Kaliiiiiiiiii](https://github.com/kaliiiiiiiiii/)
</details>
> [!IMPORTANT]
> By the nature of OS-level events (which can only impact actionable windows), this package can only be used with headful browsers.
> [!WARNING]
> Pressing `SHIFT` or `CAPSLOCK` manually on Windows affects `input.type(text) as well.`
> [!WARNING]
> Because Chrome does not recognize Input Events to specific tabs, these methods can only be used on the active tab.
> Chrome Tabs do have their own process with a process id (pid), but these can not be controlled using Input Events as they´re just engines.
Read the [Documentation](https://vinyzu.gitbook.io/cdp-patches-documentation). Only the part for [Playwright](https://vinyzu.gitbook.io/cdp-patches-documentation/input/playwright-usage) is relevant.
---
## Development
Read the [CONTRIBUTING.md](https://github.com/Vinyzu/Botright/blob/main/docs/CONTRIBUTING.md) file.
---
## Copyright and License
© [Vinyzu](https://github.com/Vinyzu/)
[GNU GPL](https://choosealicense.com/licenses/gpl-3.0/)
(Commercial Usage is allowed, but source, license and copyright has to made available. Botright does not provide and Liability or Warranty)
---
## Authors
[Vinyzu](https://github.com/Vinyzu/),
[Kaliiiiiiiiii](https://github.com/kaliiiiiiiiii/)
Raw data
{
"_id": null,
"home_page": "https://github.com/imamousenotacat/re-cdp-patches/",
"name": "re-cdp-patches",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "re-patchright, re-browser-use, playwright, automation, fingerprints, fingerprinting, dataset, data, chrome, patching, web-automation",
"author": "Vinyzu, Kaliiiiiiiiii (slightly modified by imamousenotacat)",
"author_email": null,
"download_url": null,
"platform": null,
"description": "<h1 align=\"center\">\n re-cdp-patches\n</h1>\n\n\n<p align=\"center\">\n <a href=\"https://github.com/imamousenotacat/re-cdp-patches/blob/main/LICENSE\">\n <img src=\"https://img.shields.io/badge/License-GNU%20GPL-green\">\n </a>\n <a href=\"https://python.org/\">\n <img src=\"https://img.shields.io/badge/python-3.9‐3.12-blue\">\n </a>\n <a href=\"https://pypi.org/project/re-cdp-patches/\">\n <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/re-cdp-patches.svg?color=1182C3\">\n </a>\n <br>\n <a href=\"https://github.com/imamousenotacat/re-cdp-patches/actions\">\n <img src=\"https://github.com/imamousenotacat/re-cdp-patches/actions/workflows/ci.yml/badge.svg\">\n </a>\n <a href=\"http://mypy-lang.org\">\n <img src=\"http://www.mypy-lang.org/static/mypy_badge.svg\">\n </a>\n <a href=\"https://github.com/PyCQA/flake8\">\n <img src=\"https://img.shields.io/badge/code%20quality-Flake8-green.svg\">\n </a>\n <a href=\"https://github.com/ambv/black\">\n <img src=\"https://img.shields.io/badge/code%20style-black-black.svg\">\n </a>\n <a href=\"https://github.com/PyCQA/isort\">\n <img src=\"https://img.shields.io/badge/imports-isort-yellow.svg\">\n </a>\n</p>\n\nThis is a pruned version of [CDP Patches](https://github.com/Kaliiiiiiiiii-Vinyzu/CDP-Patches) that only works with Playwright and [Patchright](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright), and that I'm using to enhance the stealthiness of my [Cloudflare-defeating browser-use version](https://github.com/imamousenotacat/re-browser-use).\n\nBy using real OS-level events when clicking elements, I can bypass certain additional limitations that occur when using a VPN. \n\n\n## Install it from PyPI\n\n```bash\npip install re-cdp-patches\n```\n<details>\n <summary>Or for Full Linting</summary>\n\n#### (Includes: playwright, re-patchright)\n```bash\npip install re-cdp-patches[automation_linting]\n```\n</details>\n\n---\n\n# Leak Patches\n<details>\n <summary>Input Package</summary>\n\n### Concept: Input Domain Leaks\nBypass CDP Leaks in [Input](https://chromedevtools.github.io/devtools-protocol/tot/Input/) domains\n\n[](https://github.com/kaliiiiiiiiii/brotector)\n\nFor an interaction event `e`, the page coordinates won't ever equal the screen coordinates, unless Chrome is in fullscreen.\nHowever, all `CDP` input commands just set it the same by default (see [crbug#1477537](https://bugs.chromium.org/p/chromium/issues/detail?id=1477537)).\n```js\nvar is_bot = (e.pageY == e.screenY && e.pageX == e.screenX)\nif (is_bot && 1 >= outerHeight - innerHeight){ // fullscreen\n is_bot = false\n}\n```\n\nFurthermore, CDP can't dispatch `CoalescedEvent`'s ([demo](https://omwnk.codesandbox.io/)).\n\nAs we don't want to patch Chromium itsself, let's just dispatch this event at OS-level!\n\n---\n\n## Usage\n\n```py\nfrom cdp_patches.input import SyncInput\n\nsync_input = SyncInput(pid=pid)\n# Or\nsync_input = SyncInput(browser=browser)\n\n# Dispatch Inputs\nsync_input.click(\"left\", 100, 100) # Left click at (100, 100)\nsync_input.double_click(\"left\", 100, 100) # Left double-click at (100, 100)\nsync_input.down(\"left\", 100, 100) # Left mouse button down at (100, 100)\nsync_input.up(\"left\", 100, 100) # Left mouse button up at (100, 100)\nsync_input.move(100, 100) # Move mouse to (100, 100)\nsync_input.scroll(\"down\", 10) # Scroll down by 10 lines\nsync_input.type(\"Hello World!\") # Type \"Hello World!\"\n```\n\n## Async Usage\n\n```py\nimport asyncio\n\nfrom cdp_patches.input import AsyncInput\n\nasync def main():\n async_input = await AsyncInput(pid=pid)\n # Or\n async_input = await AsyncInput(browser=browser)\n \n # Dispatch Inputs\n await async_input.click(\"left\", 100, 100) # Left click at (100, 100)\n await async_input.double_click(\"left\", 100, 100) # Left double-click at (100, 100)\n await async_input.down(\"left\", 100, 100) # Left mouse button down at (100, 100)\n await async_input.up(\"left\", 100, 100) # Left mouse button up at (100, 100)\n await async_input.move(100, 100) # Move mouse to (100, 100)\n await async_input.scroll(\"down\", 10) # Scroll down by 10 lines\n await async_input.type(\"Hello World!\") # Type \"Hello World!\"\n\nif __name__ == '__main__':\n asyncio.run(main())\n```\n\n### TODO\n- [ ] Improve mouse movement timings.\n- [ ] Implement extensive testing.\n\n#### Owner: [Vinyzu](https://github.com/Vinyzu/)\n#### Co-Maintainer: [Kaliiiiiiiiii](https://github.com/kaliiiiiiiiii/)\n</details>\n\n\n> [!IMPORTANT] \n> By the nature of OS-level events (which can only impact actionable windows), this package can only be used with headful browsers.\n\n> [!WARNING] \n> Pressing `SHIFT` or `CAPSLOCK` manually on Windows affects `input.type(text) as well.`\n\n> [!WARNING] \n> Because Chrome does not recognize Input Events to specific tabs, these methods can only be used on the active tab. \n> Chrome Tabs do have their own process with a process id (pid), but these can not be controlled using Input Events as they\u00b4re just engines.\n\n\nRead the [Documentation](https://vinyzu.gitbook.io/cdp-patches-documentation). Only the part for [Playwright](https://vinyzu.gitbook.io/cdp-patches-documentation/input/playwright-usage) is relevant.\n\n---\n\n## Development\n\nRead the [CONTRIBUTING.md](https://github.com/Vinyzu/Botright/blob/main/docs/CONTRIBUTING.md) file.\n\n---\n\n## Copyright and License\n\u00a9 [Vinyzu](https://github.com/Vinyzu/)\n\n[GNU GPL](https://choosealicense.com/licenses/gpl-3.0/)\n\n(Commercial Usage is allowed, but source, license and copyright has to made available. Botright does not provide and Liability or Warranty)\n\n---\n\n## Authors\n\n[Vinyzu](https://github.com/Vinyzu/), \n[Kaliiiiiiiiii](https://github.com/kaliiiiiiiiii/)\n",
"bugtrack_url": null,
"license": "GNU General Public License v3.0",
"summary": "Patching CDP (Chrome DevTools Protocol) leaks on OS level. Easy to use with Playwright/Patchright.",
"version": "0.9",
"project_urls": {
"Homepage": "https://github.com/imamousenotacat/re-cdp-patches/"
},
"split_keywords": [
"re-patchright",
" re-browser-use",
" playwright",
" automation",
" fingerprints",
" fingerprinting",
" dataset",
" data",
" chrome",
" patching",
" web-automation"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "366a40cf01203a5546df0e207d1b243125b31b6dce751166c267ca3e0d9d7c2a",
"md5": "84ef5bd3be18740782cb6603227577b9",
"sha256": "fade5e0e8c8b9d1246fdecbd1baaca2617b17e4321e23038898aef5e537d0138"
},
"downloads": -1,
"filename": "re_cdp_patches-0.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "84ef5bd3be18740782cb6603227577b9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 32353,
"upload_time": "2025-07-24T19:26:07",
"upload_time_iso_8601": "2025-07-24T19:26:07.700032Z",
"url": "https://files.pythonhosted.org/packages/36/6a/40cf01203a5546df0e207d1b243125b31b6dce751166c267ca3e0d9d7c2a/re_cdp_patches-0.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-24 19:26:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "imamousenotacat",
"github_project": "re-cdp-patches",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "numpy",
"specs": [
[
">=",
"1.26.4"
]
]
},
{
"name": "pywinauto",
"specs": [
[
">=",
"0.6.8"
]
]
},
{
"name": "requests",
"specs": [
[
">=",
"2.31.0"
]
]
},
{
"name": "websockets",
"specs": [
[
">=",
"12.0"
]
]
},
{
"name": "python-xlib",
"specs": [
[
">=",
"0.33"
]
]
}
],
"lcname": "re-cdp-patches"
}