Split _inject_greasemonkey_scripts to separate requirements.
Because flake8 was complaining about cyclomatic complexity.
This commit is contained in:
parent
abea603119
commit
32268ae66a
@ -911,6 +911,15 @@ class _WebEngineScripts(QObject):
|
||||
scripts = self._greasemonkey.all_scripts()
|
||||
self._inject_greasemonkey_scripts(scripts)
|
||||
|
||||
def _remove_all_greasemonkey_scripts(self):
|
||||
page_scripts = self._widget.page().scripts()
|
||||
for script in page_scripts.toList():
|
||||
if script.name().startswith("GM-"):
|
||||
log.greasemonkey.debug('Removing script: {}'
|
||||
.format(script.name()))
|
||||
removed = page_scripts.remove(script)
|
||||
assert removed, script.name()
|
||||
|
||||
def _inject_greasemonkey_scripts(self, scripts=None, injection_point=None,
|
||||
remove_first=True):
|
||||
"""Register user JavaScript files with the current tab.
|
||||
@ -934,12 +943,7 @@ class _WebEngineScripts(QObject):
|
||||
# have been added elsewhere, like the one for stylesheets.
|
||||
page_scripts = self._widget.page().scripts()
|
||||
if remove_first:
|
||||
for script in page_scripts.toList():
|
||||
if script.name().startswith("GM-"):
|
||||
log.greasemonkey.debug('Removing script: {}'
|
||||
.format(script.name()))
|
||||
removed = page_scripts.remove(script)
|
||||
assert removed, script.name()
|
||||
self._remove_all_greasemonkey_scripts()
|
||||
|
||||
if not scripts:
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user