cdp-patches


Namecdp-patches JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/Kaliiiiiiiiii-Vinyzu/CDP-Patches/
SummaryPatching CDP (Chrome DevTools Protocol) leaks on OS level. Easy to use with Playwright, Selenium, and other web automation tools.
upload_time2024-04-20 18:45:10
maintainerNone
docs_urlNone
authorVinyzu, Kaliiiiiiiiii
requires_python>=3.8
licenseGNU General Public License v3.0
keywords botright playwright browser automation fingerprints fingerprinting dataset data selenium chrome patching web-automation
VCS
bugtrack_url
requirements numpy pywinauto requests websockets python-xlib
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">
    CDP-Patches v1.0
</h1>


<p align="center">
    <a href="https://github.com/Kaliiiiiiiiii-Vinyzu/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&#8208;3.12-blue">
    </a>
    <a href="https://pypi.org/project/cdp-patches/">
        <img alt="PyPI" src="https://img.shields.io/pypi/v/cdp-patches.svg?color=1182C3">
    </a>
    <a href="https://pepy.tech/project/cdp-patches">
        <img alt="PyPI" src="https://static.pepy.tech/badge/cdp-patches">
    </a>
    <br>
    <a href="https://github.com/Kaliiiiiiiiii-Vinyzu/CDP-Patches/actions">
        <img src="https://github.com/Kaliiiiiiiiii-Vinyzu/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>

## Install it from PyPI

```bash
pip install cdp-patches
```
<details>
    <summary>Or for Full Linting</summary>

#### (Includes: playwright, botright, selenium, selenium_driverless)
```bash
pip install 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

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)

---

## 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/Kaliiiiiiiiii-Vinyzu/CDP-Patches/",
    "name": "cdp-patches",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "botright, playwright, browser, automation, fingerprints, fingerprinting, dataset, data, selenium, chrome, patching, web-automation",
    "author": "Vinyzu, Kaliiiiiiiiii",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/b4/e4/96be8469c0ebf9ce06fa9563961012e0d32efe8c7445b63927d548940d5a/cdp_patches-1.0.1.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">\r\n    CDP-Patches v1.0\r\n</h1>\r\n\r\n\r\n<p align=\"center\">\r\n    <a href=\"https://github.com/Kaliiiiiiiiii-Vinyzu/CDP-Patches/blob/main/LICENSE\">\r\n        <img src=\"https://img.shields.io/badge/License-GNU%20GPL-green\">\r\n    </a>\r\n    <a href=\"https://python.org/\">\r\n        <img src=\"https://img.shields.io/badge/python-3.9&#8208;3.12-blue\">\r\n    </a>\r\n    <a href=\"https://pypi.org/project/cdp-patches/\">\r\n        <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/cdp-patches.svg?color=1182C3\">\r\n    </a>\r\n    <a href=\"https://pepy.tech/project/cdp-patches\">\r\n        <img alt=\"PyPI\" src=\"https://static.pepy.tech/badge/cdp-patches\">\r\n    </a>\r\n    <br>\r\n    <a href=\"https://github.com/Kaliiiiiiiiii-Vinyzu/CDP-Patches/actions\">\r\n        <img src=\"https://github.com/Kaliiiiiiiiii-Vinyzu/CDP-Patches/actions/workflows/ci.yml/badge.svg\">\r\n    </a>\r\n    <a href=\"http://mypy-lang.org\">\r\n        <img src=\"http://www.mypy-lang.org/static/mypy_badge.svg\">\r\n    </a>\r\n    <a href=\"https://github.com/PyCQA/flake8\">\r\n        <img src=\"https://img.shields.io/badge/code%20quality-Flake8-green.svg\">\r\n    </a>\r\n    <a href=\"https://github.com/ambv/black\">\r\n        <img src=\"https://img.shields.io/badge/code%20style-black-black.svg\">\r\n    </a>\r\n    <a href=\"https://github.com/PyCQA/isort\">\r\n        <img src=\"https://img.shields.io/badge/imports-isort-yellow.svg\">\r\n    </a>\r\n</p>\r\n\r\n## Install it from PyPI\r\n\r\n```bash\r\npip install cdp-patches\r\n```\r\n<details>\r\n    <summary>Or for Full Linting</summary>\r\n\r\n#### (Includes: playwright, botright, selenium, selenium_driverless)\r\n```bash\r\npip install cdp-patches[automation_linting]\r\n```\r\n</details>\r\n\r\n---\r\n\r\n# Leak Patches\r\n<details>\r\n    <summary>Input Package</summary>\r\n\r\n###  Concept: Input Domain Leaks\r\nBypass CDP Leaks in [Input](https://chromedevtools.github.io/devtools-protocol/tot/Input/) domains\r\n\r\nFor an interaction event `e`, the page coordinates won't ever equal the screen coordinates, unless Chrome is in fullscreen.\r\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)).\r\n```js\r\nvar is_bot = (e.pageY == e.screenY && e.pageX == e.screenX)\r\nif (is_bot && 1 >= outerHeight - innerHeight){ // fullscreen\r\n    is_bot = false\r\n}\r\n```\r\n\r\nFurthermore, CDP can't dispatch `CoalescedEvent`'s ([demo](https://omwnk.codesandbox.io/)).\r\n\r\nAs we don't want to patch Chromium itsself, let's just dispatch this event at OS-level!\r\n\r\n---\r\n\r\n## Usage\r\n\r\n```py\r\nfrom cdp_patches.input import SyncInput\r\n\r\nsync_input = SyncInput(pid=pid)\r\n# Or\r\nsync_input = SyncInput(browser=browser)\r\n\r\n# Dispatch Inputs\r\nsync_input.click(\"left\", 100, 100)  # Left click at (100, 100)\r\nsync_input.double_click(\"left\", 100, 100)  # Left double-click at (100, 100)\r\nsync_input.down(\"left\", 100, 100)  # Left mouse button down at (100, 100)\r\nsync_input.up(\"left\", 100, 100)  # Left mouse button up at (100, 100)\r\nsync_input.move(100, 100)  # Move mouse to (100, 100)\r\nsync_input.scroll(\"down\", 10)  # Scroll down by 10 lines\r\nsync_input.type(\"Hello World!\")  # Type \"Hello World!\"\r\n```\r\n\r\n## Async Usage\r\n\r\n```py\r\nimport asyncio\r\n\r\nfrom cdp_patches.input import AsyncInput\r\n\r\nasync def main():\r\n    async_input = await AsyncInput(pid=pid)\r\n    # Or\r\n    async_input = await AsyncInput(browser=browser)\r\n    \r\n    # Dispatch Inputs\r\n    await async_input.click(\"left\", 100, 100)  # Left click at (100, 100)\r\n    await async_input.double_click(\"left\", 100, 100)  # Left double-click at (100, 100)\r\n    await async_input.down(\"left\", 100, 100)  # Left mouse button down at (100, 100)\r\n    await async_input.up(\"left\", 100, 100)  # Left mouse button up at (100, 100)\r\n    await async_input.move(100, 100)  # Move mouse to (100, 100)\r\n    await async_input.scroll(\"down\", 10)  # Scroll down by 10 lines\r\n    await async_input.type(\"Hello World!\")  # Type \"Hello World!\"\r\n\r\nif __name__ == '__main__':\r\n    asyncio.run(main())\r\n```\r\n\r\n### TODO\r\n- [ ] Improve mouse movement timings.\r\n- [ ] Implement extensive testing.\r\n\r\n#### Owner: [Vinyzu](https://github.com/Vinyzu/)\r\n#### Co-Maintainer: [Kaliiiiiiiiii](https://github.com/kaliiiiiiiiii/)\r\n</details>\r\n\r\n\r\n> [!IMPORTANT]  \r\n> By the nature of OS-level events (which can only impact actionable windows), this package can only be used with headful browsers.\r\n\r\n> [!WARNING]  \r\n> Pressing `SHIFT` or `CAPSLOCK` manually on Windows affects `input.type(text) as well.`\r\n\r\n> [!WARNING]  \r\n> Because Chrome does not recognize Input Events to specific tabs, these methods can only be used on the active tab. \r\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.\r\n\r\n\r\nRead the [Documentation](https://vinyzu.gitbook.io/cdp-patches-documentation)\r\n\r\n---\r\n\r\n## Development\r\n\r\nRead the [CONTRIBUTING.md](https://github.com/Vinyzu/Botright/blob/main/docs/CONTRIBUTING.md) file.\r\n\r\n---\r\n\r\n## Copyright and License\r\n\u00a9 [Vinyzu](https://github.com/Vinyzu/)\r\n\r\n[GNU GPL](https://choosealicense.com/licenses/gpl-3.0/)\r\n\r\n(Commercial Usage is allowed, but source, license and copyright has to made available. Botright does not provide and Liability or Warranty)\r\n\r\n---\r\n\r\n## Authors\r\n\r\n[Vinyzu](https://github.com/Vinyzu/), \r\n[Kaliiiiiiiiii](https://github.com/kaliiiiiiiiii/)\r\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, Selenium, and other web automation tools.",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/Kaliiiiiiiiii-Vinyzu/CDP-Patches/"
    },
    "split_keywords": [
        "botright",
        " playwright",
        " browser",
        " automation",
        " fingerprints",
        " fingerprinting",
        " dataset",
        " data",
        " selenium",
        " chrome",
        " patching",
        " web-automation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "03b4668e27e173d86cc87d678be0e8f8f8369bef40d4db24eb285bfb33beea84",
                "md5": "e1113ff8e4891c5a33a682d04a658b15",
                "sha256": "ff1c02709f3073256015ecdee675f8c3d657f44884a28f50da858b6a533968c6"
            },
            "downloads": -1,
            "filename": "cdp_patches-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e1113ff8e4891c5a33a682d04a658b15",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 32911,
            "upload_time": "2024-04-20T18:45:08",
            "upload_time_iso_8601": "2024-04-20T18:45:08.977711Z",
            "url": "https://files.pythonhosted.org/packages/03/b4/668e27e173d86cc87d678be0e8f8f8369bef40d4db24eb285bfb33beea84/cdp_patches-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b4e496be8469c0ebf9ce06fa9563961012e0d32efe8c7445b63927d548940d5a",
                "md5": "928d544f8d45e1dc20b3b8e4e8cc76c8",
                "sha256": "1207c1760b03e820b27d79dec2e17a17bc146477e20f891ffe41e94e13114f00"
            },
            "downloads": -1,
            "filename": "cdp_patches-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "928d544f8d45e1dc20b3b8e4e8cc76c8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 38549,
            "upload_time": "2024-04-20T18:45:10",
            "upload_time_iso_8601": "2024-04-20T18:45:10.835459Z",
            "url": "https://files.pythonhosted.org/packages/b4/e4/96be8469c0ebf9ce06fa9563961012e0d32efe8c7445b63927d548940d5a/cdp_patches-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-20 18:45:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Kaliiiiiiiiii-Vinyzu",
    "github_project": "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": "cdp-patches"
}
        
Elapsed time: 0.66426s