Battledudes.io Menu Music Toggle

Add custom menu music to Battledudes.io with a toggle button

  1. // ==UserScript==
  2. // @name Battledudes.io Menu Music Toggle
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Add custom menu music to Battledudes.io with a toggle button
  6. // @author trịnh HƯng
  7. // @match https://battledudes.io/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Replace 'YOUR_AUDIO_FILE_URL' with the actual URL of your audio file
  15. var audioFileUrl = 'https://surviv-halloween.pro/audio/ambient/menu_music_01.mp3';
  16.  
  17. // Create an audio element
  18. var audioElement = document.createElement('audio');
  19. audioElement.src = audioFileUrl;
  20. audioElement.loop = true;
  21.  
  22. // Append the audio element to the body
  23. document.body.appendChild(audioElement);
  24.  
  25. // Play the audio when the script runs
  26. audioElement.play();
  27.  
  28. // Function to toggle the audio on and off
  29. function toggleAudio() {
  30. if (audioElement.paused) {
  31. // If paused, play the audio
  32. audioElement.play();
  33. } else {
  34. // If playing, pause the audio
  35. audioElement.pause();
  36. }
  37. }
  38.  
  39. // Create a toggle button
  40. var toggleButton = document.createElement('button');
  41. toggleButton.innerHTML = 'Toggle Music';
  42. toggleButton.style.position = 'fixed';
  43. toggleButton.style.top = '10px';
  44. toggleButton.style.right = '10px';
  45. toggleButton.style.zIndex = '9999';
  46. toggleButton.addEventListener('click', toggleAudio);
  47.  
  48. // Append the button to the body
  49. document.body.appendChild(toggleButton);
  50. })();