I have the Problem, that i want to insert a Javascript Code in an Anki Card via the HTML Editor and it keeps getting deleted.
I know this is, due to security risks involving Javascripts and i also know that you can insert Javascript via the template-editor.
Now in my case the problem with this is that i want to create quite a few Cards with different Scripts and the option to do it via templates would simply get to messy over time(imagine having around 100 to 200 templates).
So does anyone know how to bypass this security feature or knows an addon that does this?
1 Like
Hi, eval
seems to work in card templates: eval() - JavaScript | MDN
Note the big red warning box at the top.
I suppose as you long you ensure you are the only one who ever edits your cards, you're mostly safe. Don't put code someone else wrote for you in your cards, if you do this.
Your_code_field:
Don’t put <script>
tags in the field, instead write the code without that into the raw html editor.
console.log('hello world');
Your card template:
<script>
// Goodbye, security
eval(`{{Your_code_field}}`);
</script>
2 Likes
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.