Revert "Try to fix intermittent per-domain stylesheets".
This reverts commit 905c863598e7ce08c3e8641921a570fd54275901.
This commit is contained in:
parent
92211caea4
commit
7141f9a2be
@ -801,7 +801,7 @@ class _WebEngineScripts(QObject):
|
|||||||
def _update_stylesheet(self, url=None):
|
def _update_stylesheet(self, url=None):
|
||||||
"""Update the custom stylesheet in existing tabs."""
|
"""Update the custom stylesheet in existing tabs."""
|
||||||
css = shared.get_user_stylesheet(url=url)
|
css = shared.get_user_stylesheet(url=url)
|
||||||
code = javascript.assemble('stylesheet', 'set_css', css, delay=True)
|
code = javascript.assemble('stylesheet', 'set_css', css)
|
||||||
self._tab.run_js_async(code)
|
self._tab.run_js_async(code)
|
||||||
|
|
||||||
def _inject_early_js(self, name, js_code, *,
|
def _inject_early_js(self, name, js_code, *,
|
||||||
@ -1226,6 +1226,9 @@ class WebEngineTab(browsertab.AbstractTab):
|
|||||||
# the old icon is still displayed.
|
# the old icon is still displayed.
|
||||||
self.icon_changed.emit(QIcon())
|
self.icon_changed.emit(QIcon())
|
||||||
|
|
||||||
|
url = self.url(requested=True)
|
||||||
|
self._update_stylesheet(url)
|
||||||
|
|
||||||
@pyqtSlot(QUrl)
|
@pyqtSlot(QUrl)
|
||||||
def _on_predicted_navigation(self, url):
|
def _on_predicted_navigation(self, url):
|
||||||
"""If we know we're going to visit an URL soon, change the settings.
|
"""If we know we're going to visit an URL soon, change the settings.
|
||||||
|
@ -64,28 +64,14 @@ def _convert_js_arg(arg):
|
|||||||
arg, type(arg).__name__))
|
arg, type(arg).__name__))
|
||||||
|
|
||||||
|
|
||||||
def assemble(module, function, *args, delay=False):
|
def assemble(module, function, *args):
|
||||||
"""Assemble a javascript file and a function call."""
|
"""Assemble a javascript file and a function call."""
|
||||||
js_args = ', '.join(_convert_js_arg(arg) for arg in args)
|
js_args = ', '.join(_convert_js_arg(arg) for arg in args)
|
||||||
if module == 'window':
|
if module == 'window':
|
||||||
parts = ['window', function]
|
parts = ['window', function]
|
||||||
else:
|
else:
|
||||||
parts = ['window', '_qutebrowser', module, function]
|
parts = ['window', '_qutebrowser', module, function]
|
||||||
if delay:
|
code = '"use strict";\n{}({});'.format('.'.join(parts), js_args)
|
||||||
code = '''
|
|
||||||
"use strict";
|
|
||||||
if (document.readyState !== "loading") {{
|
|
||||||
{parts}({args});
|
|
||||||
}} else {{
|
|
||||||
window.addEventListener("DOMContentLoaded", () => {{
|
|
||||||
{parts}({args});
|
|
||||||
}});
|
|
||||||
}}
|
|
||||||
'''
|
|
||||||
code = code.format(parts='.'.join(parts), args=js_args)
|
|
||||||
else:
|
|
||||||
code = '"use strict";\n{}({});'.format('.'.join(parts), js_args)
|
|
||||||
# print(code)
|
|
||||||
return code
|
return code
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user