-
Notifications
You must be signed in to change notification settings - Fork 0
/
userscript.js
37 lines (31 loc) · 1.05 KB
/
userscript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// ==UserScript==
// @name Autoplay Audio For AnkiWeb
// @namespace popyoung
// @version 1.00
// @description A js almost written by ChatGPT
// @author popyoung
// @match https://ankiuser.net/study/
// @grant none
// @license MIT
// ==/UserScript==
(function () {
'use strict';
//Thanks to ChatGPT
var checkBtn = setInterval(function () {
var audioElements = document.getElementsByTagName("audio");
var currentAudio = 0;
var playNextAudio = function () {
if (currentAudio < audioElements.length) {
if (!audioElements[currentAudio].className.includes("played")) {
audioElements[currentAudio].play();
audioElements[currentAudio].className += " played";
audioElements[currentAudio].addEventListener("ended", function () {
currentAudio++;
playNextAudio();
});
}
}
}
playNextAudio();
}, 200);
})();