ErogameScape SQL Table Linker

SQLのテーブルにあるゲームIDをリンク化(ページ遷移後も対応)

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         ErogameScape SQL Table Linker
// @namespace    https://erogamescape.dyndns.org/
// @version      1.3
// @description  SQLのテーブルにあるゲームIDをリンク化(ページ遷移後も対応)
// @author       Kdroidwin
// @match        https://erogamescape.dyndns.org/~ap2/ero/toukei_kaiseki/usersql_exec.php?sql_id=*
// @match        https://erogamescape.org/~ap2/ero/toukei_kaiseki/usersql_exec.php?sql_id=*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function linkifyGameIDs() {
        document.querySelectorAll('td').forEach(td => {
            const text = td.textContent.trim();
            const match = text.match(/^\d+$/); // 数字のみのセルを探す
            if (match) {
                const gameId = match[0];
                if (!td.querySelector('a')) { // 既にリンクがない場合のみ処理
                    const link = document.createElement('a');
                    link.href = `https://erogamescape.dyndns.org/~ap2/ero/toukei_kaiseki/game.php?game=${gameId}`;
                    link.textContent = gameId;
                    link.style.color = 'blue'; // 視認しやすいように色を変更
                    link.style.textDecoration = 'underline';
                    td.textContent = '';
                    td.appendChild(link);
                }
                td.id = `game-${gameId}`; // ID を設定
            }
        });
    }

    // 初回実行
    linkifyGameIDs();

    // MutationObserverで動的な変更を監視し、ページ遷移後も適用
    const observer = new MutationObserver(linkifyGameIDs);
    observer.observe(document.body, { childList: true, subtree: true });
})();