Franc Gossin Blog: Making Anki card by yourself

Franc Gossin Blog by Franc Gossin is licensed under CC BY-NC-ND 4.0

2025-03-24

Making Anki card by yourself

Making Anki card by yourself is usually a very annoying process. However with some programming technology you can make it faster and easier.

For example, on a dictionary website, you usually want to copy the word itself and its definition.

function xp(xpath){
    let results = [];
    let q = document.evaluate(
        xpath,
        document,
        null,
        XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
        null
    )
    for (let i = 0, length = q.snapshotLength; i < length; ++i) {
        results.push(q.snapshotItem(i));
    }
    return results;
} 

This Javascript function can get elements by XPATH.

Then use genanki-js (Documentation) to save your deck as apkg file. You may also need jszip, sql.js and FileSaver.js with some manipulation.

An example of generating Anki deck on the Collins German-English Dictionary is here.

Screenshot:


No comments:

Post a Comment