Skip Cards Add-on

Hello, guys! I’ve created an add-on that allows users to skip cards and review them after all the other cards are done.

It is simple, but helpful. I’d love to get some feedback.

Thanks!

https://ankiweb.net/shared/info/1484305783

How is this different from burying the cards? I checked the code on GitHub and didn’t see a difference (and skipped cards are never shown at the end of the session)

I was trying to do something similar. I found this old addon that seemed to do the trick (defer/postpone card for later today (selective bury and unbury)), but I wanted to tag the files instead of leaving them in short term memory.

I seemed to get it to work on my version using the help of google gemini since I am far from a programmer (did basic python classes online just for fun).

I am curious as to whether or not this code is decent and worth sharing.

from anki.hooks import addHook
from anki.lang import _
from aqt.reviewer import Reviewer
from aqt.utils import tooltip
from aqt import mw
from aqt.qt import *
from anki.utils import ids2str

# 1. Configuration for the tag name
TAG_NAME = "later_not_now"

def load_config(conf):
    global config
    config = conf
load_config(mw.addonManager.getConfig(__name__))
mw.addonManager.setConfigUpdatedAction(__name__, load_config) 

def bury_and_tag():
    card = mw.reviewer.card
    if not card:
        return
    
    # Add the tag to the note
    note = card.note()
    note.add_tag(TAG_NAME)
    mw.col.update_note(note) # Modern way to save note changes
    
    # Standard Anki Bury
    mw.checkpoint(_("Bury + Tag"))
    mw.col.sched.bury_cards([card.id]) # Note the underscore in bury_cards
    mw.reset()
    tooltip(f"Buried. Added tag: {TAG_NAME}")

def addShortcuts21(shortcuts):
    shortcuts.append((config['later_shortcut'], bury_and_tag))
addHook("reviewStateShortcuts", addShortcuts21)

def limited_unbury_by_tag():
    """
    Finds cards with the tag, unburies them, and removes the tag.
    """
    # 1. Find the card IDs currently buried with our tag
    card_ids = mw.col.find_cards(f"tag:{TAG_NAME} is:buried")
    
    if not card_ids:
        tooltip('No buried cards found with that tag.')
        return

    mw.checkpoint("Unbury by Tag")
    
    # 2. Unbury the cards using the modern scheduler method
    mw.col.sched.unbury_cards(card_ids)
    
    # 3. Remove the tag from the notes
    nids = mw.col.db.list(f"select distinct nid from cards where id in {ids2str(card_ids)}")
    for nid in nids:
        note = mw.col.get_note(nid)
        note.remove_tag(TAG_NAME)
        mw.col.update_note(note)
        
    mw.reset()
    tooltip(f"Unburied {len(card_ids)} cards and removed tags.")

# Set up the menu item
action = QAction(mw)
action.setText("limited unbury (by tag)")
action.setShortcut(QKeySequence(config["limited_unbury_shortcut"]))
mw.form.menuTools.addAction(action)
action.triggered.connect(limited_unbury_by_tag)