<!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.95); /* 透明度を0.9→0.95に変更 */
        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.95); /* 透明度を0.9→0.95に変更 */
    }
    .mod-header { padding: 10px; cursor: grab; user-select: none; text-align: left; border-bottom: 0.3px 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: 0.3px solid #888; 
        position: relative;
    }
    .first-item { border-top: 0.3px solid #888; }
    .switch-label { 
        color: #fff; 
        font-family: "Times New Roman", serif; 
        font-size: 14px; 
        width: 100%;
        text-align: center; /* 中央揃えに変更 */
    }
    .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;
    }
</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" onclick="toggleFunction('coin1')">
      <span class="switch-label" style="font-size: 15px;">コイン1億固定</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('coin2')">
      <span class="switch-label" style="font-size: 15px;">コイン2億固定</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('medal')">
      <span class="switch-label" style="font-size: 15px;">メダル2億固定</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('maxScore')">
      <span class="switch-label" style="font-size: 15px;">スコア21億</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('tsumCount')">
      <span class="switch-label" style="font-size: 15px;">ツム獲得数5万</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('levelMax')">
      <span class="switch-label" style="font-size: 15px;">プレイヤーLvMax</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('levelUnlock')">
      <span class="switch-label" style="font-size: 12px;">ツムレベルロック解除スキップ</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('autoChain')">
      <span class="switch-label" style="font-size: 15px;">オートチェーン</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('singleClear')">
      <span class="switch-label" style="font-size: 15px;">1つ消し</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('allChain')">
      <span class="switch-label" style="font-size: 15px;">全ツムチェーン</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('tsumBoost')">
      <span class="switch-label" style="font-size: 15px;">ツム増量</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('instantEnd')">
      <span class="switch-label" style="font-size: 15px;">即終了</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('gachaSkip')">
      <span class="switch-label" style="font-size: 15px;">ガチャスキップ</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('pickupSkip')">
      <span class="switch-label" style="font-size: 15px;">ピックアップスキップ</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('resultSkip')">
      <span class="switch-label" style="font-size: 15px;">リザルトスキップ</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('matchSkip')">
      <span class="switch-label" style="font-size: 15px;">試合結果スキップ</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('rootAlert')">
      <span class="switch-label" style="font-size: 15px;">ルート検出削除</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('lineBypass')">
      <span class="switch-label" style="font-size: 15px;">LINE同意bypass</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('hideItems')">
      <span class="switch-label" style="font-size: 15px;">アイテム非表示</span>
    </div>
    <div class="switch-container" onclick="toggleFunction('speed100x')">
      <span class="switch-label" style="font-size: 15px;">速度×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, "A1BEA0F2", 0x1040C0, "01209CD2"],
        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, "1f2003d5"],
        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>