This can be done using a card template.
A script that runs the function after a specified time has elapsed.
Summary
<script>
function createTimer(delay) {
setTimeout(function() {
nameFunction();
}, delay);
}
createTimer(20000);
</script>
A script showing the answer.
Summary
<script>
try {
// AnkiDroid
showAnswer();
} catch {
// Desktop
pycmd("ans");
}
</script>
A function for responding to a card.
Summary
<script>
function rateAnswer(rating) {
pycmd('ease ' + rating);
}
</script>
An alternative taken from here
https://ankiweb.net/shared/info/510199145
Summary
<script>
//determine platform
platform = '';
if (!document.documentElement.classList.contains("mobile")) {
platform = 'desk';
} else if (document.documentElement.classList.contains("android")) {
//var jsApiContract = { version: "0.0.3", developer: "eltaurus@inbox.lt" };
//var api = new AnkiDroidJS(jsApiContract);
platform = 'android';
}
</script>
<script>
function answerAgain() {
if (platform === 'desk') {
pycmd('ease1');
} else if (platform === 'android') {
buttonAnswerEase1();
}
}
function answerHard() {
if (platform === 'desk') {
pycmd('ease2');
} else if (platform === 'android') {
buttonAnswerEase2();
}
}
function answerGood() {
if (platform === 'desk') {
pycmd('ease3');
} else if (platform === 'android') {
buttonAnswerEase3();
}
}
function answerEasy() {
if (platform === 'desk') {
pycmd('ease4');
} else if (platform === 'android') {
buttonAnswerEase4();
}
}