Adding Card informations in "Card Info" view, and auto-resfreshing them?

Hello,

Right now I’m working on some leech detector that is computing some metrics based on the revlog of a card.

I’d like, to put them in the “Card Info” view, that I use side-by-side with my review window.

I’ve been able to inject them as a different table and/or in the stat table of the “Card Info”, with the hook “webview_did_inject_style_into_page”. but unfortunately this hook doesn’t seem to refresh every time a card change, and I’m also a bit clueless about how to get dynamically that new card infos.

Right now, I’ve done some horrible hacks to be able to detect when the cell containing “Card ID” changed in the Card Info view, and updating the targetCell. But the targetCell, value, can’t be giving by the python code since the card info I was able to get the first time through mw.col.sched.getCard().id never change anymore.

So I don’t know if anyone has some ideas on how I could achieve this ?

Of course, I could always fallback to add those details in the “back” of a card after a review, and on some external window, but I thought it would be nice to be able to see those infos in the Card Info too

1 Like

For the problem with communication to Python the new ID so then the webview can receive the new informations, I found out “pycmd” + callback that allowed me to do the back-and-forth between the Card Info view and the Python code :slight_smile:

1 Like

For the problem of determining the Card ID, I noticed I could use the document.location.href

1 Like