Newgrounds Open Audio and Copy URL

Opens audio link from og:audio meta tag and copies to clipboard

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Newgrounds Open Audio and Copy URL
// @namespace    http://tampermonkey.net/
// @version      2025-08-25
// @description  Opens audio link from og:audio meta tag and copies to clipboard
// @author       YouTubeDrawaria
// @match        https://www.newgrounds.com/audio/listen/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=newgrounds.com
// @grant        GM_setClipboard
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Wait for the document to be fully loaded
    window.addEventListener('load', function() {
        const audioUrl = document.querySelector('meta[property="og:audio"]').getAttribute('content');

        if (audioUrl) {
            const button = document.createElement('button');
            button.textContent = 'Open Audio and Copy URL';
            button.style.position = 'fixed';
            button.style.bottom = '10px';
            button.style.left = '10px';
            button.style.zIndex = '10000';
            button.style.padding = '10px';
            button.style.backgroundColor = '#f0f0f0';
            button.style.border = '1px solid #ccc';
            button.style.cursor = 'pointer';

            button.addEventListener('click', async () => {
                // Open in new window
                window.open(audioUrl, '_blank');

                // Copy to clipboard using Tampermonkey's GM_setClipboard
                if (typeof GM_setClipboard !== 'undefined') {
                    GM_setClipboard(audioUrl);
                    console.log('Audio URL copied to clipboard using GM_setClipboard:', audioUrl);
                } else {
                    // Fallback for standard clipboard API if GM_setClipboard is not available
                    try {
                        await navigator.clipboard.writeText(audioUrl);
                        console.log('Audio URL copied to clipboard using navigator.clipboard:', audioUrl);
                    } catch (err) {
                        console.error('Failed to copy audio URL:', err);
                    }
                }
            });

            document.body.appendChild(button);
        } else {
            console.error('Could not find the audio URL in the meta tag.');
        }
    });
})();