Content Injector

AnkiWeb addon 166455199

Injects global HTML, CSS, and JavaScript into cards at render time, with toggles and configurable files, without altering card content.
AI-generated summary; may contain mistakes.

formattingappearance

Open on AnkiWeb GitHub Ask about alternatives

AnkiWeb

Rating
2 (πŸ‘ 2 Β· πŸ‘Ž 0)
Updated
2020-09-03
Anki versions
2.1.33~
Description language
en

Maintenance

abandoned

  • Last update or commit was 732 days before the snapshot (2024-09-29).

Will it work on my Anki?

Version branches
Min AnkiMax AnkiUpdated
2.1.212.1.33+2020-09-03
History across monthly snapshots

Loading…

Similar addons

Anki_Terminator_Companion

Optimizes an Anki AI sidebar companion by freezing idle webviews, speeding ad-block lookups, disabling animations, and adding formatting-safe prompts and navigation.

card-creationaiformattingappearance

Rating 0 πŸ‘ 0 Β· πŸ‘Ž 0 ⭐ 0 Anki 2.1.1~ Updated 2026-08-31
Deck Browser CSS

Injects additional CSS into the deck browser or replaces the original styling without modifying Anki's files, supporting Anki 23.12 and later.

appearance

Rating 19 πŸ‘ 18 Β· πŸ‘Ž 1 ⭐ 4 Anki 23.12~ Updated 2024-03-27
Review Feedback

Provides customizable AnkiDroid-like feedback after answering cards, configurable via Tools menu or JSON for HTML/CSS injection, timing, and location.

review-flowappearance

Rating 1 πŸ‘ 1 Β· πŸ‘Ž 0 ⭐ 0 Anki 23.12.1~ Updated 2025-08-09
CSS Injector - Change default editor styles

Allows overriding default editor styles, including lists and links inside fields and the overall editor, by editing CSS files, with night mode and note-type-specific options.

formattingappearance

Rating 21 πŸ‘ 21 Β· πŸ‘Ž 0 ⭐ 9 Anki 2.1.58~ Updated 2023-02-21

README

anki-content-injector

Anki add-on ID: 166455199

Current version: 0.9

Overview

This is an add-on for Anki 2.1 that allows for a the insertion of arbitrary HTML, CSS, and JavaScript content into cards before they are displayed. It can be used in a similar fashion to Arthaey's similar add-on for Anki 2.0 to keep a global stylesheet whose rules are applied to every card. However, beyond its support of additional content types, it has a number of advantages over Arthaey's add-on:

  • A restart is not needed to reload the HTML/CSS/JS content; it is injected into the template at render-time using the prepareQA hook added in 2.1.0b16. In fact, this is more or less just a thin wrapper around prepareQA.
  • Template-local CSS still applies (Arthaey's add-on replaced the template CSS instead of adding to it).
  • Support for more than one file.
  • Global HTML/CSS/JS can be toggled without having to delete or move the file(s).

Do note that this add-on makes no changes to the content of your cards; all changes are limited to when the card is being rendered. Be sure that your decks work without your injection files before sharing them with others!

Instructions

First, install the add-on from Anki's menu with the above ID.

Place any of the files _global.html, _global.css, and _global.js in your profile's collection.media directory. With default settings, these files will be injected into your cards.

There will be a new toggle for "Inject Global Content" in the Tools menu. This can be unchecked to stop the add-on from injecting the content, instead rendering the cards with only the layout on their template. In the card layout editor, there is also a new checkbox to toggle injection. This is a temporary toggle and applies only to the layout editor window.

Configuration

  • startEnabled: (Boolean, default: true). Whether to enable the plugin on Anki startup. Note that the plugin can always be turned on and off via its toggle in the Tools menu.
  • injectFiles: (Array (String), default: [ "_global.css", "_global.html", "_global.js" ]). Names of the files to inject. These files must be inside the collection.media directory. If one of the files is not found, it is silently ignored.
  • injectAtTail: (Boolean, default: false) Inject the files at the end of the card instead of at the beginning. This won't have any effect if you're just using this for CSS, but for HTML and JS files it will obviously change where the content is placed or when the script is run, respectively.

Support

The code for this project is on GitHub.

If you discover an error or have a request, submit an issue.

Feel free to write reviews on the add-on page but I cannot guarantee that I will check them; GitHub is the better way to get my attention.

Building & packaging

Please ignore this section if you just want to use the add-on. This is for add-on developers only.

All code is in the __init__.py file. The Makefile will create everything needed to upload the add-on to AnkiWeb. Since the release number is specified in the documentation, be sure to check out the appropriate version tag before building the add-on! Then, go to the AnkiWeb add-on portal and choose to update the add-on. Choose the created content-injector.zip archive as the add-on file, and then paste the contents of the new description.html into the description field.

License

This addon is licensed under the same license as Anki itself (GNU Affero General Public License 3).