Pekora WineD3D Command Grabber

Intercepts pekora-player links and formats them with WineD3D and OpenGL overrides.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Pekora WineD3D Command Grabber
// @namespace    http://tampermonkey.net
// @version      2.6
// @description  Intercepts pekora-player links and formats them with WineD3D and OpenGL overrides.
// @author       You
// @match        *://*.pekora.zip/*
// @grant        GM_setClipboard
// @grant        GM_addStyle
// @run-at       document-start
// @license me
// ==/UserScript==

(function() {
    'use strict';

    const capturedLinks = [];

    // 1. Intercept protocol launch attempts
    const originalOpen = window.open;
    window.open = function(url, ...args) {
        if (url && url.includes('pekora-player:')) {
            saveLink(url);
        }
        return originalOpen.apply(this, [url, ...args]);
    };

    function saveLink(url) {
        const time = new Date().toLocaleTimeString();
        // Extract the raw protocol link if it's part of a larger string
        const match = url.match(/pekora-player:[^'"]+/);
        const rawLink = match ? match[0] : url;

        // Format for WineD3D + OpenGL
        const formattedCommand = `WINEDLLOVERRIDES="d3d11,dxgi=b" wine start '${rawLink}' --force-opengl`;

        capturedLinks.push(formattedCommand);
        console.log("%c[Pekora Grabber] Wine command generated!", "color: #00ff00; font-weight: bold;");
    }

    // 2. Observer for Dynamic "Play" Buttons
    const observer = new MutationObserver(() => {
        const links = document.querySelectorAll('a[href^="pekora-player:"]');
        links.forEach(link => {
            if (!link.dataset.grabbed) {
                saveLink(link.href);
                link.dataset.grabbed = "true";
            }
        });
    });
    observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true });

    // 3. Persistent Pink Button UI
    const container = document.createElement('div');
    container.id = 'pekora-ui-container';
    container.innerHTML = `<button id="copy-log-btn">Copy Join Link</button>`;
    document.documentElement.appendChild(container);

    document.getElementById('copy-log-btn').onclick = () => {
        if (capturedLinks.length > 0) {
            const latest = capturedLinks[capturedLinks.length - 1];
            GM_setClipboard(latest);

            // Visual feedback
            const btn = document.getElementById('copy-log-btn');
            btn.innerText = 'Copied Command!';
            setTimeout(() => { btn.innerText = 'Copy Join Link'; }, 2000);
        } else {
            alert('No link detected yet. Click "Play" on the site to capture it.');
        }
    };

    GM_addStyle(`
        #pekora-ui-container { position:fixed; top:10px; right:10px; z-index:2147483647; }
        #pekora-ui-container button {
            padding:12px 18px; background:#ff66aa; color:#fff; border:none;
            border-radius:5px; cursor:pointer; font-weight:bold; font-family:sans-serif;
            box-shadow: 0 4px 10px rgba(0,0,0,0.3);
        }
        #pekora-ui-container button:hover { background:#ff4499; }
    `);
})();