diff --git a/css_tab_mapping.py b/css_tab_mapping.py index 90908f2..13d7194 100644 --- a/css_tab_mapping.py +++ b/css_tab_mapping.py @@ -119,6 +119,9 @@ async def connect(self, skip_if_connected : bool = False) -> Result: self.tab = await injector.get_tab_lambda(lambda x : _match_tab(x, self.tab_names_regex, self.tab_url_parts)) Log(f"Connected to tab {self.get_name()}") except Exception as e: + if (str(e) == "Tab not found by lambda"): + return Result(False, str(e), False) + return Result(False, f"{str(e)} ({self.tab_names_regex})") return Result(True) diff --git a/css_theme.py b/css_theme.py index a7a086c..a38e14e 100644 --- a/css_theme.py +++ b/css_theme.py @@ -18,6 +18,14 @@ def __init__(self, themePath : str, json : dict, configPath : str = None): self.bundled = self.configPath != self.themePath self.enabled = False self.json = json + self.priority_mod = 0 + + try: + if (os.path.join(themePath, "PRIORITY")): + with open(os.path.join(themePath, "PRIORITY")) as fp: + self.priority_mod = int(fp.readline().strip()) + except: + pass if (json is None): if not os.path.exists(os.path.join(themePath, "theme.css")): diff --git a/css_themepatchcomponent.py b/css_themepatchcomponent.py index d40b824..10366fa 100644 --- a/css_themepatchcomponent.py +++ b/css_themepatchcomponent.py @@ -71,7 +71,8 @@ def generate(self) -> Result: except Exception as e: return Result(False, str(e)) - self.inject.css = f":root {{ {self.css_variable}: url({join('/themes_custom/', self.value.replace(' ', '%20'))}) }}" + path = join('/themes_custom/', self.value.replace(' ', '%20').replace('\\', '/')) + self.inject.css = f":root {{ {self.css_variable}: url({path}) }}" return Result(True) async def generate_and_reinject(self) -> Result: diff --git a/css_utils.py b/css_utils.py index 26503e8..726ae52 100644 --- a/css_utils.py +++ b/css_utils.py @@ -31,11 +31,11 @@ def Log(text : str): Logger.info(f"[CSS_Loader] {text}") class Result: - def __init__(self, success : bool, message : str = "Success"): + def __init__(self, success : bool, message : str = "Success", log : bool = True): self.success = success self.message = message - if not self.success: + if log and not self.success: Log(f"Result failed! {message}") def raise_on_failure(self): diff --git a/main.py b/main.py index 2542acd..4bf1045 100644 --- a/main.py +++ b/main.py @@ -15,6 +15,7 @@ from css_server import start_server ALWAYS_RUN_SERVER = False +IS_STANDALONE = False try: if not store_or_file_config("no_redirect_logs"): @@ -45,6 +46,9 @@ def on_modified(self, event): class Plugin: + async def is_standalone(self) -> bool: + return IS_STANDALONE + async def dummy_function(self) -> bool: return True @@ -396,6 +400,8 @@ async def _load(self): async def _set_theme_score(self, theme : Theme): if theme.name not in self.scores: self.scores[theme.name] = 0 + + self.scores[theme.name] += theme.priority_mod for x in theme.dependencies: dependency = await self._get_theme(self, x) @@ -460,6 +466,7 @@ async def _main(self): if __name__ == '__main__': ALWAYS_RUN_SERVER = True + IS_STANDALONE = True import logging logging.basicConfig( diff --git a/package.json b/package.json index fa170f8..a4ade6b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "SDH-CssLoader", - "version": "1.6.1", + "version": "1.6.2", "description": "A css loader", "scripts": { "build": "shx rm -rf dist && rollup -c",