ErogameScape SQL Table Linker

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

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