Pekora WineD3D Command Grabber

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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