Toonio Audio Downloader

Audio Downloader from Toon

目前為 2024-09-11 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name            Toonio Audio Downloader
// @name:ru         Toonio Audio Downloader
// @namespace       nland.fun
// @version         1.0
// @description     Audio Downloader from Toon
// @description:ru  Скачивание Озвучки из Мульта
// @author          MrVladar (@vlad246YT)
// @match           https://toonio.ru/t/*
// @match           https://en.toonio.ru/t/*
// @icon            https://www.google.com/s2/favicons?sz=64&domain=toonio.ru
// @license         MIT
// @grant           none
// ==/UserScript==

(function() {
    'use strict';

    function createDownloadButton(audioUrl, fileName, buttonText) {
        const button = document.createElement('a');
        button.className = 'nav';
        button.href = audioUrl;
        button.download = fileName;
        button.innerHTML = `<span class="far fa-music"></span>${buttonText}`;
        return button;
    }

    const iframe = document.getElementById('player');
    if (iframe) {
        const src = iframe.getAttribute('src');
        const audioParam = new URLSearchParams(src.split('?')[1]).get('audio');
        if (audioParam) {
            const currentDomain = window.location.hostname;
            const audioUrl = `https://${currentDomain}/Toons/audio/${audioParam}`;
            const buttonText = currentDomain === 'en.toonio.ru' ? 'Download audio' : 'Скачать озвучку';
            const musicTitleElement = document.querySelector('h3.music');
            let fileName = 'audio.mp3';
            if (musicTitleElement) {
                fileName = musicTitleElement.textContent.trim() + '.mp3';
            }

            const actionBlocks = document.querySelectorAll('.toon_actions');
            actionBlocks.forEach(block => {
                const downloadButton = createDownloadButton(audioUrl, fileName, buttonText);
                block.appendChild(downloadButton);
            });
        }
    }
})();