ErogameScape SQL Table Linker

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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