Insert qutebrowser scripts on DocumentCreation and DocumentReady
In #3521, the injection point was changed to DocumentReady as a fix for https://bugreports.qt.io/browse/QTBUG-66011 / #3490. However, that prevents e.g. using hints before a page is fully loaded, which can be annoying on a mobile connection. Instead, just run the scripts twice, which won't hurt and makes sure they're available.
This commit is contained in:
parent
64530375ab
commit
fac0f66e52
@ -640,17 +640,21 @@ class WebEngineTab(browsertab.AbstractTab):
|
||||
utils.read_file('javascript/webelem.js'),
|
||||
utils.read_file('javascript/caret.js'),
|
||||
])
|
||||
scripts = self._widget.page().scripts()
|
||||
|
||||
script = QWebEngineScript()
|
||||
# We can't use DocumentCreation here as WORKAROUND for
|
||||
# https://bugreports.qt.io/browse/QTBUG-66011
|
||||
script.setInjectionPoint(QWebEngineScript.DocumentReady)
|
||||
script.setInjectionPoint(QWebEngineScript.DocumentCreation)
|
||||
script.setSourceCode(js_code)
|
||||
|
||||
page = self._widget.page()
|
||||
script.setWorldId(QWebEngineScript.ApplicationWorld)
|
||||
|
||||
# FIXME:qtwebengine what about runsOnSubFrames?
|
||||
page.scripts().insert(script)
|
||||
scripts.insert(script)
|
||||
|
||||
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-66011
|
||||
script2 = QWebEngineScript()
|
||||
script2.setInjectionPoint(QWebEngineScript.DocumentReady)
|
||||
script2.setSourceCode(js_code)
|
||||
script2.setWorldId(QWebEngineScript.ApplicationWorld)
|
||||
scripts.insert(script2)
|
||||
|
||||
def _install_event_filter(self):
|
||||
self._widget.focusProxy().installEventFilter(self._mouse_event_filter)
|
||||
|
Loading…
Reference in New Issue
Block a user