Getting profile name from javascript

I would like show a flag (icon) on the card depending on which profile is seeing the card. I would have a field with a list of names of those who want to see the flag. If one of those names matches the profile name, then the flag is shown. Any ideas? Thanks alot!

Each different profile will have its own set of cards. They will not share them.

Also, there is no special field for the profile: Field Replacements - Anki Manual (ankiweb.net). I don’t know if it’s possible in JavaScript.

I understand, but decks can be shared with others. This is the situation I’m referring to. I’m sharing the deck with another user, but want to change something on the card depending on who is seeing it.

I did look into pycmd to gain access to the profile name but couldn’t find a way to get the profile name into javascript.

There’s no way to do that with only JavaScript. You have to write an add-on.

on python side:

mw.pm.name
mw.pm.profiles()

to return string from python to javascript
run pycmd from javascript side and set up python handler as normal. after running python code above to get profile name you return the profile name string from the handler function and the return value from pycmd will be set to that value. so on javascript it will look like something like

profile = pycmd('getProfile')
1 Like

I want to thank all of you for your input. From the comments I understand that without an addon I can’t access this information. I therefore chose a different solution.
Flags are linked to the user profile and are accessible from javascript. It is just a matter of checking which flag was set. Although this solution serves my purpose, it unfortunately prevents me from using flags for anything else since only one flag can be set.
Many thanks!

1 Like