From efcea65596f5a2a01db00d77d27916e55414b48e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 12 Jun 2015 11:24:04 +0200 Subject: [PATCH] Add --quiet argument to :jseval. --- doc/help/commands.asciidoc | 7 +++++-- qutebrowser/browser/commands.py | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index 9e387f42e..fe71e8eb0 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -244,12 +244,15 @@ Toggle the web inspector. [[jseval]] === jseval -Syntax: +:jseval 'js_code'+ +Syntax: +:jseval [*--quiet*] 'js-code'+ Evaluate a JavaScript string. ==== positional arguments -* +'js_code'+: The string to evaluate. +* +'js-code'+: The string to evaluate. + +==== optional arguments +* +*-q*+, +*--quiet*+: Don't show resulting JS object. ==== note * This command does not split arguments after the last argument and handles quotes literally. diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 9ba2b3cc2..af8815a78 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1566,15 +1566,19 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window', maxsplit=0, no_cmd_split=True) - def jseval(self, js_code): + def jseval(self, js_code, quiet=False): """Evaluate a JavaScript string. Args: js_code: The string to evaluate. + quiet: Don't show resulting JS object. """ frame = self._current_widget().page().mainFrame() out = frame.evaluateJavaScript(js_code) + if quiet: + return + if out is None: # Getting the actual error (if any) seems to be difficult. The # error does end up in BrowserPage.javaScriptConsoleMessage(), but