Pekora WineD3D Command Grabber

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

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да инсталирате разширение, като например Tampermonkey .

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

// ==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; }
    `);
})();