In JavaScript, there are times when you want to use some variables used in Anki. For example,) reviewer . card . id .
However, sharing data between JavaScript and Python is not as simple as you might think. There are several ways to do this, but the following method is simple.
Use the mw.web.eval function in Python to pass variables to JavaScript. If you have variables that you want to keep, use window.localStorage. If you want to get the value of a JavaScript variable, use mw.web.evalWithCallback.