Audio in Drawaria

play music!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Audio in Drawaria
// @namespace    https://tampermonkey.net/
// @version      1.2
// @license      MIT
// @author       Dipsan dhimal
// @icon         https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTZDUqjRko7Ws05tXGYs6VXi40C2R4qo5dQdA&s
// @match        https://drawaria.online/*
// @grant        none
// @description  play music!
// ==/UserScript==

(function () {
    'use strict';

    // Create container box
    const box = document.createElement('div');
    box.style.position = 'fixed';
    box.style.top = '10px';
    box.style.left = '10px';
    box.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
    box.style.color = '#fff';
    box.style.padding = '10px';
    box.style.borderRadius = '8px';
    box.style.zIndex = '9999';
    box.style.fontFamily = 'Arial';
    box.style.fontSize = '14px';
    box.innerHTML = '<b>🎵 Audio Player</b><br><br>';

    // File input
    const fileInput = document.createElement('input');
    fileInput.type = 'file';
    fileInput.accept = 'audio/*';
    fileInput.style.marginBottom = '5px';
    box.appendChild(fileInput);

    // Audio element (hidden)
    const audio = document.createElement('audio');
    audio.controls = false;
    audio.style.display = 'none';
    document.body.appendChild(audio);

    // Play button
    const playBtn = document.createElement('button');
    playBtn.textContent = '▶️ Play';
    playBtn.style.marginRight = '5px';
    playBtn.onclick = () => {
        if (fileInput.files.length > 0) {
            const file = fileInput.files[0];
            audio.src = URL.createObjectURL(file);
            audio.play();
        } else {
            alert('Please upload an audio file first.');
        }
    };
    box.appendChild(playBtn);

    // Stop button
    const stopBtn = document.createElement('button');
    stopBtn.textContent = '⏹️ Stop';
    stopBtn.onclick = () => {
        audio.pause();
        audio.currentTime = 0;
    };
    box.appendChild(stopBtn);

    // Add to page
    document.body.appendChild(box);
})();