Pekora WineD3D Command Grabber

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

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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; }
    `);
})();