From 1fcc08d82883f2c83ce489826c1c3b8bcd2ca84f Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 26 Mar 2026 19:39:09 +0100 Subject: [PATCH] Small tidyup --- .../blueprint/settings/browser_profile/__init__.py | 3 +++ .../browser_profile/templates/browser_profiles.html | 7 ++++++- changedetectionio/content_fetchers/__init__.py | 4 ---- changedetectionio/content_fetchers/playwright/CDP.py | 1 + changedetectionio/content_fetchers/puppeteer.py | 1 + changedetectionio/content_fetchers/webdriver_selenium.py | 1 + 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/changedetectionio/blueprint/settings/browser_profile/__init__.py b/changedetectionio/blueprint/settings/browser_profile/__init__.py index 4b55668d..7faacb36 100644 --- a/changedetectionio/blueprint/settings/browser_profile/__init__.py +++ b/changedetectionio/blueprint/settings/browser_profile/__init__.py @@ -25,6 +25,8 @@ def construct_blueprint(datastore: ChangeDetectionStore): browser_profile_form.fetch_backend.choices = fetcher_choices fetcher_supports_screenshots = {name: True for name, _ in fetcher_choices} + fetcher_requires_connection_url = {name: True for name, cls in cf.FETCHERS.items() + if getattr(cls, 'requires_connection_url', False)} # Table shows default built-in profiles first, then user-created profiles store_profiles = datastore.data['settings']['application'].get('browser_profiles', {}) @@ -44,6 +46,7 @@ def construct_blueprint(datastore: ChangeDetectionStore): reserved_browser_profile_names=RESERVED_MACHINE_NAMES, fetcher_choices=fetcher_choices, fetcher_supports_screenshots=fetcher_supports_screenshots, + fetcher_requires_connection_url=fetcher_requires_connection_url, current_default_profile=current_default, editing_machine_name=editing_machine_name, ) diff --git a/changedetectionio/blueprint/settings/browser_profile/templates/browser_profiles.html b/changedetectionio/blueprint/settings/browser_profile/templates/browser_profiles.html index 1d37b81c..5c0282f9 100644 --- a/changedetectionio/blueprint/settings/browser_profile/templates/browser_profiles.html +++ b/changedetectionio/blueprint/settings/browser_profile/templates/browser_profiles.html @@ -80,7 +80,7 @@
{{ render_field(browser_profile_form.fetch_backend, id="profile-fetch-backend") }}
-
+
{{ render_field(browser_profile_form.browser_connection_url) }} {{ _('Optional — override the system CDP/WebSocket URL for this profile only (e.g.') }} ws://my-chrome:3000).
@@ -128,13 +128,18 @@ function setDefaultProfile(machineName) { } const fetcherSupportsBrowser = {{ fetcher_supports_screenshots | tojson }}; +const fetcherRequiresConnectionUrl = {{ fetcher_requires_connection_url | tojson }}; function updateBrowserFieldVisibility() { const fetchBackend = document.getElementById('profile-fetch-backend').value; const isBrowser = !!fetcherSupportsBrowser[fetchBackend]; + const isCdp = !!fetcherRequiresConnectionUrl[fetchBackend]; document.querySelectorAll('.browser-only-field').forEach(function(el) { el.style.display = isBrowser ? '' : 'none'; }); + document.querySelectorAll('.cdp-only-field').forEach(function(el) { + el.style.display = isCdp ? '' : 'none'; + }); } document.addEventListener('DOMContentLoaded', function() { diff --git a/changedetectionio/content_fetchers/__init__.py b/changedetectionio/content_fetchers/__init__.py index da2164e3..bc285105 100644 --- a/changedetectionio/content_fetchers/__init__.py +++ b/changedetectionio/content_fetchers/__init__.py @@ -89,10 +89,6 @@ def _register_default_browser_profiles(): # Populate the registry at module load time _load_fetchers() -# Backwards-compat alias: stored data may reference 'playwright' (pre-refactor name). -# Map it to playwright_cdp which is the CDP-based fetcher that replaced it. -if 'playwright_cdp' in FETCHERS and 'playwright' not in FETCHERS: - FETCHERS['playwright'] = FETCHERS['playwright_cdp'] _register_default_browser_profiles() diff --git a/changedetectionio/content_fetchers/playwright/CDP.py b/changedetectionio/content_fetchers/playwright/CDP.py index 1401ea48..1a1d234f 100644 --- a/changedetectionio/content_fetchers/playwright/CDP.py +++ b/changedetectionio/content_fetchers/playwright/CDP.py @@ -11,6 +11,7 @@ from changedetectionio.content_fetchers.playwright import PlaywrightBaseFetcher class fetcher(PlaywrightBaseFetcher): fetcher_description = "Playwright Chrome (CDP/Remote)" + requires_connection_url = True def __init__(self, proxy_override=None, custom_browser_connection_url=None, **kwargs): super().__init__(proxy_override=proxy_override, custom_browser_connection_url=custom_browser_connection_url, **kwargs) diff --git a/changedetectionio/content_fetchers/puppeteer.py b/changedetectionio/content_fetchers/puppeteer.py index f6dfd014..1ca54601 100644 --- a/changedetectionio/content_fetchers/puppeteer.py +++ b/changedetectionio/content_fetchers/puppeteer.py @@ -168,6 +168,7 @@ async def capture_full_page(page, screenshot_format='JPEG', watch_uuid=None, loc class fetcher(Fetcher): fetcher_description = "Puppeteer Chromium" + requires_connection_url = True browser = None browser_type = '' diff --git a/changedetectionio/content_fetchers/webdriver_selenium.py b/changedetectionio/content_fetchers/webdriver_selenium.py index d7fad1be..354ea868 100644 --- a/changedetectionio/content_fetchers/webdriver_selenium.py +++ b/changedetectionio/content_fetchers/webdriver_selenium.py @@ -9,6 +9,7 @@ from changedetectionio.pluggy_interface import hookimpl class fetcher(Fetcher): fetcher_description = "Selenium WebDriver Chrome" + requires_connection_url = True proxy = None proxy_url = None