ninja33 / ODH

A chrome extension to show online dictionary content.
MIT License
1.4k stars 240 forks source link

Creat more field ? #336

Open locpham122k opened 2 months ago

locpham122k commented 2 months ago

I am developing my own dict. Alongside these field Expression, Reading, Definition, Definitions,... I wonder if there's any way to create more fields such as Synonyms, which would display on options window like the others ?

ninja33 commented 2 months ago

OK, assume you are familiar with HTML/CSS/JS realated tech stack.

you can put other fields data in spare fields like extrainfo, then you go to anki card template to put this fields on card front/back, the content of extrainfo can be any format of string (splitted by | , or even json string). but embrace it with a hidden class like

.hidden{
  display:none;
}

<div id='extra' class='hidden'>{{extrainfo}}</div>

so, you card will not display it by default, and then you can put some js code to retrieve those info

<script>
  const extrainfo=document.getElementById("extra").innerText;
  // manipulate, split or paser {{extrainfo}} as you wish and put it on card front/back DOM
</script>