<!DOCTYPE html>
<html>
<head>
  <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no"/>
  <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.9); z-index: 1000; width: 202px; border: 1px solid #333; font-size: 14px; }
    .mod-header { padding: 10px; cursor: grab; user-select: none; text-align: center; border-bottom: 0.3px solid #888; } /* より細く、より白に */
    .scroll-container { overflow-y: auto; max-height: 70vh; }
    .switch-container { padding: 12px 10px; text-align: center; min-height: 44px; display: flex; align-items: center; justify-content: center; border-bottom: 0.3px solid #888; } /* より細く、より白に */
    .first-item { border-top: 0.3px solid #888; } /* より細く、より白に */
    .switch-label { color: #fff; font-family: "Times New Roman", serif; font-size: 14px; }
    .switch-container.active { background-color: #B31b1b; }
    .mod-title { 
      font-size: 18px; /* 少し小さく */
      font-family: -apple-system, sans-serif;
      font-weight: bold;
      margin: 0;
      padding: 0;
    }
  </style>
</head>
<body>
  <div class="mod-menu" id="mod-menu">
    <div class="mod-header" id="mod-header">
      <h2 class="mod-title">Tsum Peni Mod</h2>
    </div>
    <div class="scroll-container">
      <div class="switch-container first-item" 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('medal')"><span class="switch-label">メダル100万倍</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" onclick="toggleFunction('levelUnlock')"><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('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 class="switch-container" onclick="toggleFunction('hideItems')"><span class="switch-label">アイテム非表示</span></div>
      <div class="switch-container" onclick="toggleFunction('speed100x')"><span class="switch-label">速度×100</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, levelMax: false, maxScore: false,
      medal: false, tsumCount: false, autoChain: false, singleClear: false,
      allChain: false, tsumBoost: false, gachaSkip: false, pickupSkip: false,
      rootAlert: false, lineBypass: false, resultSkip: false, levelUnlock: false,
      hideItems: false, matchSkip: false, instantEnd: false, speed100x: false
    };

    function toggleFunction(funcName) {
      const container = event.currentTarget;
      functionStates[funcName] = !functionStates[funcName];
      container.classList.toggle('active');
      
      const patches = {
        coin1: ["TsumTsum", 0x103CD4, "4173A7F2", 0x1040C0, "014099D2"],
        coin2: ["TsumTsum", 0x103A5C, "617DA152", 0x103A60, "01409872"],
        levelMax: ["TsumTsum", 0x740308, "e17a020b"],
        maxScore: ["TsumTsum", 0x72D21c, "c0035fd6"],
        medal: ["TsumTsum", 0x2ea790, "617Da152", 0x2ea794, "01409872"],
        tsumCount: ["TsumTsum", 0x732318, "014C9D52"],
        autoChain: ["TsumTsum", 0x779504, "1f2003d5"],
        singleClear: ["TsumTsum", 0x73A71C, "016a9852"],
        allChain: ["TsumTsum", 0x779CFC, "c0035fd6"],
        tsumBoost: ["TsumTsum", 0x734040, "29250071"],
        gachaSkip: ["TsumTsum", 0x7103f4, "c0035fd6"],
        pickupSkip: ["TsumTsum", 0x70FFBC, "c0035fd6"],
        rootAlert: ["TsumTsum", 0x365f14, "c0035fd6"],
        lineBypass: ["TsumTsum", 0x1251BBC, "02008052"],
        resultSkip: ["TsumTsum", 0x742100, "1f2003d5"],
        levelUnlock: ["TsumTsum", 0x63c3cc, "c0035fd6"],
        hideItems: ["TsumTsum", 0x299054, "c0035fd6"],
        matchSkip: ["TsumTsum", 0x722D20, "340080D2"],
        instantEnd: ["TsumTsum", 0x72be5c, "1f3003d5"],
        speed100x: ["TsumTsum", 0x302940, "0090241E"]
      };

      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>