Toonio Audio Downloader

Audio Downloader from Toon

  1. // ==UserScript==
  2. // @name Toonio Audio Downloader
  3. // @name:ru Toonio Audio Downloader
  4. // @namespace nland.fun
  5. // @version 1.0
  6. // @description Audio Downloader from Toon
  7. // @description:ru Скачивание Озвучки из Мульта
  8. // @author MrVladar (@vlad246YT)
  9. // @match https://toonio.ru/t/*
  10. // @match https://en.toonio.ru/t/*
  11. // @icon https://www.google.com/s2/favicons?sz=64&domain=toonio.ru
  12. // @license MIT
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. function createDownloadButton(audioUrl, fileName, buttonText) {
  20. const button = document.createElement('a');
  21. button.className = 'nav';
  22. button.href = audioUrl;
  23. button.download = fileName;
  24. button.innerHTML = `<span class="far fa-music"></span>${buttonText}`;
  25. return button;
  26. }
  27.  
  28. const iframe = document.getElementById('player');
  29. if (iframe) {
  30. const src = iframe.getAttribute('src');
  31. const audioParam = new URLSearchParams(src.split('?')[1]).get('audio');
  32. if (audioParam) {
  33. const currentDomain = window.location.hostname;
  34. const audioUrl = `https://${currentDomain}/Toons/audio/${audioParam}`;
  35. const buttonText = currentDomain === 'en.toonio.ru' ? 'Download audio' : 'Скачать озвучку';
  36. const musicTitleElement = document.querySelector('h3.music');
  37. let fileName = 'audio.mp3';
  38. if (musicTitleElement) {
  39. fileName = musicTitleElement.textContent.trim() + '.mp3';
  40. }
  41.  
  42. const actionBlocks = document.querySelectorAll('.toon_actions');
  43. actionBlocks.forEach(block => {
  44. const downloadButton = createDownloadButton(audioUrl, fileName, buttonText);
  45. block.appendChild(downloadButton);
  46. });
  47. }
  48. }
  49. })();