diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index 68653e844..abcb15194 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -1226,6 +1226,7 @@ These commands are mainly intended for debugging. They are hidden if qutebrowser |<>|Print LRU cache stats. |<>|Show the debugging console. |<>|Crash for debugging purposes. +|<>|Dump the current page's content to a file. |<>|Evaluate a python string and display the results as a web page. |<>|Trace executed code via hunter. |<>|Execute a webaction. @@ -1251,6 +1252,18 @@ Crash for debugging purposes. ==== positional arguments * +'typ'+: either 'exception' or 'segfault'. +[[debug-dump-page]] +=== debug-dump-page +Syntax: +:debug-dump-page [*--plain*] 'dest'+ + +Dump the current page's content to a file. + +==== positional arguments +* +'dest'+: Where to write the file to. + +==== optional arguments +* +*-p*+, +*--plain*+: Write plain text instead of HTML. + [[debug-pyeval]] === debug-pyeval Syntax: +:debug-pyeval 's'+ diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 74febf62a..16e28ccb9 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1225,6 +1225,24 @@ class CommandDispatcher: tab.setHtml(highlighted, current_url) tab.viewing_source = True + @cmdutils.register(instance='command-dispatcher', scope='window', + debug=True) + def debug_dump_page(self, dest, plain=False): + """Dump the current page's content to a file. + + Args: + dest: Where to write the file to. + plain: Write plain text instead of HTML. + """ + web_view = self._current_widget() + mainframe = web_view.page().mainFrame() + if plain: + data = mainframe.toPlainText() + else: + data = mainframe.toHtml() + with open(dest, 'w', encoding='utf-8') as f: + f.write(data) + @cmdutils.register(instance='command-dispatcher', name='help', completion=[usertypes.Completion.helptopic], scope='window')