Autoplay Audio For AnkiWeb

A js almost written by ChatGPT

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