Content Injector

AnkiWeb addon 166455199

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

appearancecard-templates

Open on AnkiWeb GitHub Find alternatives

AnkiWeb

Votes
2 (πŸ‘ 2 Β· πŸ‘Ž 0)
Updated
2020-09-03
Anki versions
2.1.33~
License
AGPL-3.0 (from the README)
Virus scan
No ClamAV match A match does not prove malware. No match does not prove that the code is safe.
Languages
Python, JSON
Description language
en

Maintenance

abandoned

  • Last update or commit: 2024-09-29 (763 days before the snapshot).
  • Commits in the last year: 0.
  • Issues: 1 open, 5 closed.
  • Pull requests: 0 open, 2 merged.
  • Median first response: 112 hours (7 answered issues and pull requests).
  • Outside pull requests: 100% of 2 merged.

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

Export Anki cards as picture

Exports Anki cards as images using customizable Jinja2 HTML templates and CSS, with configurable resolution, auto-cropping, cloze replacement, excluded fields, and per-note/card-type templates.

exportcard-templates

1 votes 0% approval πŸ‘ 0 Β· πŸ‘Ž 1 ⭐ 0 Anki 24.06.2~ Updated 2024-06-18
Review Feedback

Provides customizable AnkiDroid-style feedback after answering a card, with configurable HTML/CSS injection pages, presets, and advanced injection ID, duration, and location settings.

review-flowappearance

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

Overrides Anki editor and field styling through editable CSS files, supporting night-mode, note-type, field-specific, and version-dependent style customization.

formattingappearance

21 votes 85% approval πŸ‘ 21 Β· πŸ‘Ž 0 ⭐ 9 Anki 2.1.58~ Updated 2023-02-21
Custom editor keymap

Customizes editor keyboard shortcuts to insert characters, HTML, JavaScript, or file contents based on configured key-and-modifier mappings, including Arrow+Alt symbols.

shortcutsobsolete

1 votes 21% approval πŸ‘ 1 Β· πŸ‘Ž 0 Anki 2.1.46~ Updated 2021-10-13

Description

Current version: 0.9 (Commit bcfab182) 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).

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).