From 4204a8de9a19fefb8098422a291dcbe6495e6580 Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Sun, 31 May 2015 21:32:16 +0200 Subject: [PATCH] Add ui.modal-js-dialog to restore the default JS dialogs --- doc/help/settings.asciidoc | 1 + qutebrowser/browser/webpage.py | 6 ++++++ qutebrowser/config/configdata.py | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index d3c571aa3..4886d9dcd 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -45,6 +45,7 @@ |<>|Whether to hide the statusbar unless a message is shown. |<>|The format to use for the window title. The following placeholders are defined: |<>|Whether to hide the mouse cursor. +|<>|Use standard JavaScript modal dialog for alert() and confirm() |============== .Quick reference for section ``network'' diff --git a/qutebrowser/browser/webpage.py b/qutebrowser/browser/webpage.py index 005a6e300..fd6e7a7c9 100644 --- a/qutebrowser/browser/webpage.py +++ b/qutebrowser/browser/webpage.py @@ -481,6 +481,9 @@ class BrowserPage(QWebPage): def javaScriptAlert(self, _frame, msg): """Override javaScriptAlert to use the statusbar.""" log.js.debug("alert: {}".format(msg)) + if config.get('ui', 'modal-js-dialog'): + return super().javaScriptAlert(_frame, msg) + if (self._is_shutting_down or config.get('content', 'ignore-javascript-alert')): return @@ -489,6 +492,9 @@ class BrowserPage(QWebPage): def javaScriptConfirm(self, _frame, msg): """Override javaScriptConfirm to use the statusbar.""" log.js.debug("confirm: {}".format(msg)) + if config.get('ui', 'modal-js-dialog'): + return super().javaScriptConfirm(_frame, msg) + if self._is_shutting_down: return False ans = self._ask("[js confirm] {}".format(msg), diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 02b8c6008..f2c68c708 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -305,6 +305,10 @@ def data(readonly=False): SettingValue(typ.Bool(), 'false'), "Whether to hide the mouse cursor."), + ('modal-js-dialog', + SettingValue(typ.Bool(), 'false'), + "Use standard JavaScript modal dialog for alert() and confirm()"), + readonly=readonly )),