DC - Object_found

Play song if object is found

  1. // ==UserScript==
  2. // @name DC - Object_found
  3. // @author Unknow
  4. // @version 1.2
  5. // @grant none
  6. // @description Play song if object is found
  7. // @match https://www.dreadcast.net/Main
  8. // @namespace InGame
  9. // ==/UserScript==
  10.  
  11. var audioElement = new Audio("https://www.thesoundarchive.com/email/tarzan-screaming.mp3");
  12. $('body').append(audioElement);
  13. $("#DC_object_found").prop('volume', '1');
  14.  
  15. let barreAction = $('span.action.inlineBlock')[0];
  16.  
  17. $(document).ready( function() {
  18. function alert_user() {
  19.  
  20.  
  21.  
  22. const string = barreAction.innerText;
  23. const regex = /Objet trouvé/i
  24.  
  25.  
  26. if (regex.test(string)) {
  27.  
  28. audioElement.load();
  29. audioElement.play();
  30.  
  31. const Timeout = setTimeout(audioElement.stop(), 3000);
  32. }
  33. }
  34.  
  35.  
  36. $(document).ajaxComplete( function(a,b,c) {
  37. if(/Check/.test(c.url)) {
  38. alert_user();
  39. }
  40. });
  41. });
  42. console.log('DC - Object found started');