diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index 9b868685..dada8d27 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -655,7 +655,8 @@ def changedetection_app(config=None, datastore_o=None): current_base_url=datastore.data['settings']['application']['base_url'], emailprefix=os.getenv('NOTIFICATION_MAIL_BUTTON_PREFIX', False), visualselector_data_is_ready=visualselector_data_is_ready, - visualselector_enabled=visualselector_enabled + visualselector_enabled=visualselector_enabled, + playwright_enabled=os.getenv('PLAYWRIGHT_DRIVER_URL', False) ) return output diff --git a/changedetectionio/content_fetcher.py b/changedetectionio/content_fetcher.py index bc902c62..5e8d1603 100644 --- a/changedetectionio/content_fetcher.py +++ b/changedetectionio/content_fetcher.py @@ -301,6 +301,9 @@ class base_html_playwright(Fetcher): accept_downloads=False ) + if len(request_headers): + context.set_extra_http_headers(request_headers) + page = context.new_page() try: page.set_default_navigation_timeout(90000) diff --git a/changedetectionio/static/js/watch-settings.js b/changedetectionio/static/js/watch-settings.js index 429013f1..b45ca95d 100644 --- a/changedetectionio/static/js/watch-settings.js +++ b/changedetectionio/static/js/watch-settings.js @@ -1,13 +1,30 @@ $(document).ready(function() { function toggle() { - if ($('input[name="fetch_backend"]:checked').val() != 'html_requests') { - $('#requests-override-options').hide(); + if ($('input[name="fetch_backend"]:checked').val() == 'html_webdriver') { + if(playwright_enabled) { + // playwright supports headers, so hide everything else + // See #664 + $('#requests-override-options #request-method').hide(); + $('#requests-override-options #request-body').hide(); + + // @todo connect this one up + $('#ignore-status-codes-option').hide(); + } else { + // selenium/webdriver doesnt support anything afaik, hide it all + $('#requests-override-options').hide(); + } + + $('#webdriver-override-options').show(); + } else { + $('#requests-override-options').show(); + $('#requests-override-options *:hidden').show(); $('#webdriver-override-options').hide(); } } + $('input[name="fetch_backend"]').click(function (e) { toggle(); }); diff --git a/changedetectionio/templates/edit.html b/changedetectionio/templates/edit.html index f76ea7c1..addcbf34 100644 --- a/changedetectionio/templates/edit.html +++ b/changedetectionio/templates/edit.html @@ -7,6 +7,7 @@ const notification_base_url="{{url_for('ajax_callback_send_notification_test')}}"; const watch_visual_selector_data_url="{{url_for('static_content', group='visual_selector_data', filename=uuid)}}"; const screenshot_url="{{url_for('static_content', group='screenshot', filename=uuid)}}"; + const playwright_enabled={% if playwright_enabled %} true {% else %} false {% endif %}; {% if emailprefix %} const email_notification_prefix=JSON.parse('{{ emailprefix|tojson }}'); @@ -81,13 +82,14 @@ {% endif %}
-
- If you're having trouble waiting for the page to be fully rendered (text missing etc), try increasing the 'wait' time here. -
- This will wait n seconds before extracting the text. -
{{ render_field(form.webdriver_delay) }} +
+ If you're having trouble waiting for the page to be fully rendered (text missing etc), try increasing the 'wait' time here. +
+ This will wait n seconds before extracting the text. +
+
{% if using_global_webdriver_wait %}
@@ -96,18 +98,20 @@ {% endif %}
-
- Request override is currently only used by the Basic fast Plaintext/HTTP Client method. -
-
+ {% if not playwright_enabled %} +
+ Request override is currently only used by the Basic fast Plaintext/HTTP Client method. +
+ {% endif %} +
{{ render_field(form.method) }}
-
+
{{ render_field(form.headers, rows=5, placeholder="Example Cookie: foobar User-Agent: wonderbra 1.0") }}
-
+
{{ render_field(form.body, rows=5, placeholder="Example { \"name\":\"John\", @@ -115,7 +119,7 @@ User-Agent: wonderbra 1.0") }} \"car\":null }") }}
-
+
{{ render_checkbox_field(form.ignore_status_codes) }}