Beispiel #1
0
 def configure(self, updates):
     useDefaultUserscripts = True
     if sanitize(A.no_default_userscripts) in updates and option(
             A.no_default_userscripts):
         logInfo(
             f"""Built-in default userscripts will be skipped due to {flag(A.no_default_userscripts)} flag."""
         )
         useDefaultUserscripts = False
     if sanitize(A.inline) in updates and option(A.inline):
         logWarning(
             f"""Only inline injection will be used due to {flag(A.inline)} flag."""
         )
     if sanitize(A.query_param_to_disable) in updates:
         logInfo(
             f"""Userscripts will not be injected when the request URL contains a `{option(A.query_param_to_disable)}` query parameter."""
         )
     if sanitize(A.userscripts_dir) in updates:
         userscripts = loadUserscripts(
             C.DEFAULT_USERSCRIPTS_DIR) if useDefaultUserscripts else []
         userscriptsDirectory = option(A.userscripts_dir)
         if userscriptsDirectory is None:
             logWarning(
                 f"No custom userscripts will be loaded, because {flag(A.userscripts_dir)} was not provided."
             )
         else:
             userscripts.extend(loadUserscripts(userscriptsDirectory))
         self.userscripts = userscripts
Beispiel #2
0
 def load(self, loader):
     loader.add_option(sanitize(T.option_inline), bool, False,
                       T.help_inline)
     loader.add_option(sanitize(T.option_recursive), bool, False,
                       T.help_recursive)
     loader.add_option(sanitize(T.option_list_injected), bool, False,
                       T.help_list_injected)
     loader.add_option(sanitize(T.option_userscripts), str,
                       DEFAULT_USERSCRIPTS_DIR, T.help_userscripts)
     loader.add_option(sanitize(T.option_query_param_to_disable), str,
                       DEFAULT_QUERY_PARAM_TO_DISABLE,
                       T.help_query_param_to_disable)
Beispiel #3
0
 def configure(self, updates):
     if sanitize(T.option_inline) in updates and option(T.option_inline):
         logWarning(
             f"""Only inline injection will be used due to {flag(T.option_inline)} flag."""
         )
     if sanitize(T.option_query_param_to_disable) in updates:
         logInfo(
             f"""Userscripts will not be injected when the request URL contains a `{option(T.option_query_param_to_disable)}` query parameter."""
         )
     if sanitize(T.option_userscripts) in updates:
         self.userscripts = loadUserscripts(
             directories=[option(T.option_userscripts)],
             recursive=option(T.option_recursive),
         )
Beispiel #4
0
 def load(self, loader):
     loader.add_option(sanitize(A.inline), bool, False, A.inline_help)
     loader.add_option(sanitize(A.no_default_userscripts), bool, False,
                       A.no_default_userscripts_help)
     loader.add_option(sanitize(A.list_injected), bool, False,
                       A.list_injected_help)
     loader.add_option(sanitize(A.bypass_csp), Optional[str],
                       A.bypass_csp_default, A.bypass_csp_help)
     loader.add_option(sanitize(A.userscripts_dir), Optional[str],
                       A.userscripts_dir_default, A.userscripts_dir_help)
     loader.add_option(sanitize(A.query_param_to_disable), str,
                       A.query_param_to_disable_default,
                       A.query_param_to_disable_help)
Beispiel #5
0
def option(key: str):
    return ctx.options.__getattr__(sanitize(key))