Greasemonkey: privatise some utility functions

This commit is contained in:
Jimmy 2017-11-27 20:06:29 +13:00
parent 0e80be2d30
commit 0381d74e9a

View File

@ -87,11 +87,11 @@ class BrowserPage(QWebPage):
self.restoreFrameStateRequested.connect( self.restoreFrameStateRequested.connect(
self.on_restore_frame_state_requested) self.on_restore_frame_state_requested)
self.loadFinished.connect( self.loadFinished.connect(
functools.partial(self.inject_userjs, self.mainFrame())) functools.partial(self._inject_userjs, self.mainFrame()))
self.frameCreated.connect(self.connect_userjs_signals) self.frameCreated.connect(self._connect_userjs_signals)
@pyqtSlot('QWebFrame*') @pyqtSlot('QWebFrame*')
def connect_userjs_signals(self, frame): def _connect_userjs_signals(self, frame):
"""Connect userjs related signals to `frame`. """Connect userjs related signals to `frame`.
Connect the signals used as triggers for injecting user Connect the signals used as triggers for injecting user
@ -100,7 +100,7 @@ class BrowserPage(QWebPage):
log.greasemonkey.debug("Connecting to frame {} ({})" log.greasemonkey.debug("Connecting to frame {} ({})"
.format(frame, frame.url().toDisplayString())) .format(frame, frame.url().toDisplayString()))
frame.loadFinished.connect( frame.loadFinished.connect(
functools.partial(self.inject_userjs, frame)) functools.partial(self._inject_userjs, frame))
def javaScriptPrompt(self, frame, js_msg, default): def javaScriptPrompt(self, frame, js_msg, default):
"""Override javaScriptPrompt to use qutebrowser prompts.""" """Override javaScriptPrompt to use qutebrowser prompts."""
@ -298,8 +298,7 @@ class BrowserPage(QWebPage):
else: else:
self.error_occurred = False self.error_occurred = False
@pyqtSlot() def _inject_userjs(self, frame):
def inject_userjs(self, frame):
"""Inject user javascripts into the page. """Inject user javascripts into the page.
Args: Args:
@ -309,7 +308,7 @@ class BrowserPage(QWebPage):
if url.isEmpty(): if url.isEmpty():
url = frame.requestedUrl() url = frame.requestedUrl()
log.greasemonkey.debug("inject_userjs called for {} ({})" log.greasemonkey.debug("_inject_userjs called for {} ({})"
.format(frame, url.toDisplayString())) .format(frame, url.toDisplayString()))
greasemonkey = objreg.get('greasemonkey') greasemonkey = objreg.get('greasemonkey')