Here's the vscode code view of our addon (left) and Anki (right) side by side.


Patching

Finding what code to patch

Your addon has full access to Anki's internal data and code. This means you can patch existing code in any way you want. This is both power and responsibilities. You can execute arbitary code on user's PC, but don't do any malicious things on the addon.

For example, my extension noctrlq disables Ctrl+Q hotkey for exiting Anki window. To do this we...

  <action name="actionExit">
   <property name="text">
    <string>E&amp;xit</string>
   </property>
   <property name="shortcut">
    <string notr="true">Ctrl+Q</string>
   </property>
  </action>
mw.form.actionExit.setShortcuts([])

That's a case of noctrlq. In a case of case_insensitive_type_answer, we need to find what code to patch.

  1. There must be a function comparing typed answer and real answer
  2. ... and it must be using case-sensitive string comparison or so.
  3. So we modify the function to be case-insensitive.