Add $QUTE_HTML and $QUTE_TEXT for userscripts.
This commit is contained in:
parent
ecb0a4e2f8
commit
2d8df76609
@ -24,6 +24,8 @@ The following environment variables will be set when an userscript is launched:
|
||||
command or key binding).
|
||||
- `QUTE_USER_AGENT`: The currently set user agent.
|
||||
- `QUTE_FIFO`: The FIFO or file to write commands to.
|
||||
- `QUTE_HTML`: The HTML source of the current page.
|
||||
- `QUTE_TEXT`: The plaintext of the current page.
|
||||
|
||||
In `command` mode:
|
||||
|
||||
|
@ -876,9 +876,14 @@ class CommandDispatcher:
|
||||
env['QUTE_TITLE'] = tabbed_browser.page_title(idx)
|
||||
|
||||
webview = tabbed_browser.currentWidget()
|
||||
if webview is not None and webview.hasSelection():
|
||||
env['QUTE_SELECTED_TEXT'] = webview.selectedText()
|
||||
env['QUTE_SELECTED_HTML'] = webview.selectedHtml()
|
||||
if webview is not None:
|
||||
if webview.hasSelection():
|
||||
env['QUTE_SELECTED_TEXT'] = webview.selectedText()
|
||||
env['QUTE_SELECTED_HTML'] = webview.selectedHtml()
|
||||
mainframe = webview.page().mainFrame()
|
||||
if mainframe is not None:
|
||||
env['QUTE_HTML'] = mainframe.toHtml()
|
||||
env['QUTE_TEXT'] = mainframe.toPlainText()
|
||||
|
||||
try:
|
||||
url = tabbed_browser.current_url()
|
||||
|
@ -518,10 +518,13 @@ class HintManager(QObject):
|
||||
"""
|
||||
cmd = context.args[0]
|
||||
args = context.args[1:]
|
||||
frame = context.mainframe
|
||||
env = {
|
||||
'QUTE_MODE': 'hints',
|
||||
'QUTE_SELECTED_TEXT': str(elem),
|
||||
'QUTE_SELECTED_HTML': elem.toOuterXml(),
|
||||
'QUTE_HTML': mainframe.toHtml(),
|
||||
'QUTE_TEXT': mainframe.toPlainText(),
|
||||
}
|
||||
url = self._resolve_url(elem, context.baseurl)
|
||||
if url is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user