From cbeb992175921a527cd1d42518312d3165416e90 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Sun, 17 Oct 2021 21:48:14 +0200 Subject: [PATCH] Fix `_legacy_card_stats()` --- pylib/anki/stats.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pylib/anki/stats.py b/pylib/anki/stats.py index 2b9cd01d1..61ff1726d 100644 --- a/pylib/anki/stats.py +++ b/pylib/anki/stats.py @@ -28,6 +28,7 @@ def _legacy_card_stats( ) -> str: "A quick hack to preserve compatibility with the old HTML string API." random_id = f"cardinfo-{base62(random.randint(0, 2 ** 64 - 1))}" + varName = random_id.replace('-', '') return f"""
@@ -38,7 +39,8 @@ def _legacy_card_stats( if ({1 if _legacy_nightmode else 0}) {{ document.documentElement.className = "night-mode"; }} - anki.cardInfo(document.getElementById('{random_id}'), {card_id}, {include_revlog}); + const {varName} = anki.cardInfo(document.getElementById('{random_id}')); + {varName}.then((c) => c.$set({{ cardId: {card_id}, includeRevlog: {str(include_revlog).lower()} }})); """