diff --git a/qutebrowser/app.py b/qutebrowser/app.py index c32a208ac..7029f8df5 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -492,8 +492,7 @@ def _init_modules(args, crash_handler): objreg.register('cache', diskcache) log.init.debug("Initializing Greasemonkey...") - gm_manager = greasemonkey.GreasemonkeyManager() - objreg.register('greasemonkey', gm_manager) + greasemonkey.init() log.init.debug("Misc initialization...") macros.init() diff --git a/qutebrowser/browser/greasemonkey.py b/qutebrowser/browser/greasemonkey.py index 1a1ec6a24..669b9d0bc 100644 --- a/qutebrowser/browser/greasemonkey.py +++ b/qutebrowser/browser/greasemonkey.py @@ -29,7 +29,7 @@ import glob import attr from PyQt5.QtCore import pyqtSignal, QObject, QUrl -from qutebrowser.utils import log, standarddir, jinja +from qutebrowser.utils import log, standarddir, jinja, objreg from qutebrowser.commands import cmdutils @@ -209,3 +209,14 @@ class GreasemonkeyManager(QObject): def all_scripts(self): """Return all scripts found in the configured script directory.""" return self._run_start + self._run_end + self._run_idle + + +def init(): + """Initialize Greasemonkey support.""" + gm_manager = GreasemonkeyManager() + objreg.register('greasemonkey', gm_manager) + + try: + os.mkdir(_scripts_dir()) + except FileExistsError: + pass