<!DOCTYPE html>
<html>
<head>
<meta content="width=device-width,initial-scale=1.0,user-scalable=no" name="viewport"/>
<meta charset="utf-8"/>
<style>
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body { font-family: "Times New Roman", serif; background-color: transparent; color: #fff; overflow: hidden; touch-action: none; width: 100vw; height: 100vh; }
    .mod-menu { 
        position: fixed; 
        top: 50%; 
        left: 50%; 
        transform: translate(-50%, -50%); 
        background-color: rgba(0, 0, 0, 0.90); /* 透明度を変更 */
        z-index: 1000; 
        width: calc(220px - 19px);
        border: 1px solid #333; 
        font-size: 14px;
        border-radius: 8px; 
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.90);
    }
    .mod-header { padding: 10px; cursor: grab; user-select: none; text-align: left; border-bottom: 1px solid #888; display: flex; align-items: center; } /* ボーダー色変更 */
    .scroll-container { overflow-y: auto; max-height: 70vh; }
    .switch-container { 
        padding: 12px 15px; 
        min-height: 44px; 
        display: flex; 
        align-items: center; 
        justify-content: center;
        border-bottom: 1px solid #888; /* ボーダー色変更 */
        position: relative;
    }
    .first-item { border-top: 1px solid #888; } /* ボーダー色変更 */
    .switch-label { 
        color: #fff; 
        font-family: "Times New Roman", serif; 
        font-size: 14px; 
        width: 100%;
        text-align: center;
        white-space: nowrap; /* 改行防止 */
    }
    .switch-container.active { background-color: rgba(255, 0, 0, 0.8); }
    .mod-title { 
      font-size: 18px;
      font-family: -apple-system, sans-serif;
      font-weight: bold;
      margin: 0;
      padding: 0;
    }
    .title-image {
      width: 24px;
      height: 24px;
      margin-right: 8px;
      background-size: contain;
      background-repeat: no-repeat;
    }
    .section-header {
      pointer-events: none;
      background-color: rgba(0, 0, 0, 0.90); /* 背景色変更 */
    }
    .section-header .switch-label {
      color: #FFD700;
      font-weight: bold;
    }
    .small-text {
      font-size: 12px; /* 小さい文字サイズ */
    }
</style>
</head>
<body>
<div class="mod-menu" id="mod-menu">
  <div class="mod-header" id="mod-header">
    <div class="title-image"></div>
    <h2 class="mod-title">Tsum Peni Mod</h2>
  </div>
  <div class="scroll-container">
    <!-- 代行セクション -->
    <div class="switch-container first-item section-header">
      <span class="switch-label">━ 代行 ━</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('coin1')">
      <span class="switch-label">コイン1億固定</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('coin2')">
      <span class="switch-label">コイン2億固定</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('medal1')">
      <span class="switch-label">メダル1億固定</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('medal')">
      <span class="switch-label">メダル2億固定</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('maxScore')">
      <span class="switch-label">スコア21億</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('tsumCount')">
      <span class="switch-label">ツム獲得数5万</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('levelMax')">
      <span class="switch-label">プレイヤーLvMax</span>
    </div>

    <!-- プレイ内設定セクション -->
    <div class="switch-container section-header">
      <span class="switch-label">━ プレイ内設定 ━</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('autoChain')">
      <span class="switch-label">オートチェーン</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('singleClear')">
      <span class="switch-label">1つ消し</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('allChain')">
      <span class="switch-label">全ツムチェーン</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('tsumBoost')">
      <span class="switch-label">ツム増量</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('instantEnd')">
      <span class="switch-label">即終了</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('oneTsumEnd')">
      <span class="switch-label">1ツム消し終了</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('speed100x')">
      <span class="switch-label">速度×100</span>
    </div>
    <!-- 非表示/スキップセクション -->
    <div class="switch-container section-header">
      <span class="switch-label">━ 非表示 / スキップ ━</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('hideItems')">
      <span class="switch-label">アイテム非表示</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('informationDelete')">
      <span class="switch-label">information削除</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('levelUnlock')">
      <span class="switch-label small-text">ツムレベルロック解除スキップ</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('gachaSkip')">
      <span class="switch-label">ガチャスキップ</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('pickupSkip')">
      <span class="switch-label">ピックアップスキップ</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('resultSkip')">
      <span class="switch-label">リザルトスキップ</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('matchSkip')">
      <span class="switch-label">試合結果スキップ</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('rootAlert')">
      <span class="switch-label">ルート検出削除</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('lineBypass')">
      <span class="switch-label">LINE同意bypass</span>
    </div>
  </div>
</div>
<script>
    h5gg.require(7.9); 
    var h5frida = h5gg.loadPlugin("h5frida", "h5frida-15.1.24.dylib");
    if (!h5frida) throw "Failed to load h5frida plugin";

    function ActiveCodePatch(fpath, vaddr, bytes) {
      if (!h5frida.ActiveCodePatch(fpath, vaddr, bytes)) {
        var result = h5frida.ApplyCodePatch(fpath, vaddr, bytes);
        alert(fpath + ":0x" + vaddr.toString(16) + "-変更失敗!\n" + fpath + ":0x" + vaddr.toString(16) + "-PatchFailed!\n" + result);
        return false;
      }
      return true;
    }

    function DeactiveCodePatch(fpath, vaddr, bytes) {
      return h5frida.DeactiveCodePatch(fpath, vaddr, bytes);
    }

    const functionStates = {
      coin1: false, coin2: false, medal1: false, medal: false, levelMax: false, 
      maxScore: false, tsumCount: false, autoChain: false, singleClear: false,
      allChain: false, tsumBoost: false, instantEnd: false, oneTsumEnd: false,
      gachaSkip: false, pickupSkip: false, resultSkip: false, matchSkip: false,
      rootAlert: false, lineBypass: false, hideItems: false, speed100x: false,
      informationDelete: false, levelUnlock: false
    };

    function toggleFunction(funcName) {
      const container = event.currentTarget;
      functionStates[funcName] = !functionStates[funcName];
      container.classList.toggle('active');

      const patchData = patches[funcName];
      const fpath = patchData[0];
      
      if (functionStates[funcName]) {
        for (let i = 1; i < patchData.length; i += 2) {
          ActiveCodePatch(fpath, patchData[i], patchData[i+1]);
        }
      } else {
        for (let i = 1; i < patchData.length; i += 2) {
          DeactiveCodePatch(fpath, patchData[i], patchData[i+1]);
        }
      }
    }

    const menu = document.getElementById('mod-menu');
    const header = document.getElementById('mod-header');
    let isDragging = false;
    let startX, startY, initialX, initialY;

    header.addEventListener('mousedown', (e) => {
      isDragging = true;
      const rect = menu.getBoundingClientRect();
      startX = e.clientX;
      startY = e.clientY;
      initialX = rect.left;
      initialY = rect.top;
      header.style.cursor = 'grabbing';
      e.preventDefault();
    });

    document.addEventListener('mousemove', (e) => {
      if (!isDragging) return;
      const dx = e.clientX - startX;
      const dy = e.clientY - startY;
      menu.style.left = `${initialX + dx}px`;
      menu.style.top = `${initialY + dy}px`;
      menu.style.transform = 'none';
    });

    document.addEventListener('mouseup', () => {
      isDragging = false;
      header.style.cursor = 'grab';
    });

    header.addEventListener('touchstart', (e) => {
      isDragging = true;
      const touch = e.touches[0];
      const rect = menu.getBoundingClientRect();
      startX = touch.clientX;
      startY = touch.clientY;
      initialX = rect.left;
      initialY = rect.top;
    }, { passive: false });

    document.addEventListener('touchmove', (e) => {
      if (!isDragging) return;
      const touch = e.touches[0];
      const dx = touch.clientX - startX;
      const dy = touch.clientY - startY;
      menu.style.left = `${initialX + dx}px`;
      menu.style.top = `${initialY + dy}px`;
      menu.style.transform = 'none';
      e.preventDefault();
    }, { passive: false });

    document.addEventListener('touchend', () => {
      isDragging = false;
    });
</script>
</body>
</html>