def _init_stylesheet(profile):
 old_script = profile.scripts().findScript('_qute_stylesheet')
 if (not old_script.isNull()):
  profile.scripts().remove(old_script)
 css = shared.get_user_stylesheet()
 source = "\n        (function() {{\n            var css = document.createElement('style');\n            css.setAttribute('type', 'text/css');\n            css.appendChild(document.createTextNode('{}'));\n            document.getElementsByTagName('head')[0].appendChild(css);\n        }})()\n    ".format(javascript.string_escape(css))
 script = QWebEngineScript()
 script.setName('_qute_stylesheet')
 script.setInjectionPoint(QWebEngineScript.DocumentReady)
 script.setWorldId(QWebEngineScript.ApplicationWorld)
 script.setRunsOnSubFrames(True)
 script.setSourceCode(source)
 profile.scripts().insert(script)

def _init_stylesheet ( profile ) : old_script = profile . scripts ( ) . findScript ( '_qute_stylesheet' ) if ( not old_script . isNull ( ) ) : profile . scripts ( ) . remove ( old_script ) css = shared . get_user_stylesheet ( ) source = "\n        (function() {{\n            var css = document.createElement('style');\n            css.setAttribute('type', 'text/css');\n            css.appendChild(document.createTextNode('{}'));\n            document.getElementsByTagName('head')[0].appendChild(css);\n        }})()\n    " . format ( javascript . string_escape ( css ) ) script = QWebEngineScript ( ) script . setName ( '_qute_stylesheet' ) script . setInjectionPoint ( QWebEngineScript . DocumentReady ) script . setWorldId ( QWebEngineScript . ApplicationWorld ) script . setRunsOnSubFrames ( True ) script . setSourceCode ( source ) profile . scripts ( ) . insert ( script )
initialize custom stylesheets .