From 522ca1d6f579b4f19f277e9423c93b57fd86f377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Bernal?= Date: Mon, 29 Jul 2024 19:17:12 +0200 Subject: [PATCH 1/4] Replace pkg_resources usage with regular file reading --- playwright_stealth/stealth.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/playwright_stealth/stealth.py b/playwright_stealth/stealth.py index 721e6f4..8ad6856 100644 --- a/playwright_stealth/stealth.py +++ b/playwright_stealth/stealth.py @@ -2,19 +2,19 @@ import json from dataclasses import dataclass from typing import Tuple, Optional, Dict +from pathlib import Path -import pkg_resources from playwright.async_api import Page as AsyncPage from playwright.sync_api import Page as SyncPage def from_file(name): """Read script from ./js directory""" - return pkg_resources.resource_string('playwright_stealth', f'js/{name}').decode() - + file_path = Path(__file__).parent / 'js' / name + return file_path.read_text(encoding='utf-8') SCRIPTS: Dict[str, str] = { - 'chrome_csi': from_file('chrome.csi.js'), + 'chrome_csi': from_file('chrome.csi.js'), 'chrome_app': from_file('chrome.app.js'), 'chrome_runtime': from_file('chrome.runtime.js'), 'chrome_load_times': from_file('chrome.load.times.js'), From 037f00932a9fa2bf2cc645f95a5d0eeb78fc22d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Bernal?= Date: Mon, 29 Jul 2024 19:31:23 +0200 Subject: [PATCH 2/4] Remove whitespace --- playwright_stealth/stealth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright_stealth/stealth.py b/playwright_stealth/stealth.py index 8ad6856..78b0842 100644 --- a/playwright_stealth/stealth.py +++ b/playwright_stealth/stealth.py @@ -14,7 +14,7 @@ def from_file(name): return file_path.read_text(encoding='utf-8') SCRIPTS: Dict[str, str] = { - 'chrome_csi': from_file('chrome.csi.js'), + 'chrome_csi': from_file('chrome.csi.js'), 'chrome_app': from_file('chrome.app.js'), 'chrome_runtime': from_file('chrome.runtime.js'), 'chrome_load_times': from_file('chrome.load.times.js'), From d24469beea04ae1869d6c8dfbb442635feb68ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Bernal?= Date: Mon, 29 Jul 2024 19:34:05 +0200 Subject: [PATCH 3/4] Add missing newline --- playwright_stealth/stealth.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/playwright_stealth/stealth.py b/playwright_stealth/stealth.py index 78b0842..08a1a5a 100644 --- a/playwright_stealth/stealth.py +++ b/playwright_stealth/stealth.py @@ -13,8 +13,9 @@ def from_file(name): file_path = Path(__file__).parent / 'js' / name return file_path.read_text(encoding='utf-8') + SCRIPTS: Dict[str, str] = { - 'chrome_csi': from_file('chrome.csi.js'), + 'chrome_csi': from_file('chrome.csi.js'), 'chrome_app': from_file('chrome.app.js'), 'chrome_runtime': from_file('chrome.runtime.js'), 'chrome_load_times': from_file('chrome.load.times.js'), From a15bdd1814029ffa466a79ff537307de989cee5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Bernal?= Date: Mon, 29 Jul 2024 19:34:46 +0200 Subject: [PATCH 4/4] Remove whitespace --- playwright_stealth/stealth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright_stealth/stealth.py b/playwright_stealth/stealth.py index 08a1a5a..636b063 100644 --- a/playwright_stealth/stealth.py +++ b/playwright_stealth/stealth.py @@ -15,7 +15,7 @@ def from_file(name): SCRIPTS: Dict[str, str] = { - 'chrome_csi': from_file('chrome.csi.js'), + 'chrome_csi': from_file('chrome.csi.js'), 'chrome_app': from_file('chrome.app.js'), 'chrome_runtime': from_file('chrome.runtime.js'), 'chrome_load_times': from_file('chrome.load.times.js'),