Epic手机喜加一 《Home - A Unique Horror Adventure》截止10.29

Android & iOS


另附:链接生成脚本(现在有了 AI 真方便)
// ==UserScript==
// @name         Epic 商店:一键生成 iOS + Android 购买链接
// @namespace    local.epic-mobile-cart
// @version      0.2.0
// @description  在 Epic 游戏页面查找移动商店中的同名商品,并生成双平台 purchase 链接
// @match        https://store.epicgames.com/*
// @run-at       document-idle
// @grant        GM_xmlhttpRequest
// @grant        GM_setClipboard
// @connect      egs-platform-service.store.epicgames.com
// @connect      store.epicgames.com
// ==/UserScript==

(() => {
  'use strict';

  // 德国属于 Epic iOS 商店支持的欧盟地区;这里仅用于查询移动商店目录。
  // 若需要其他地区,可改为对应的两位国家代码,例如 MY、US、JP、BR。
  const COUNTRY = 'DE';
  const LOCALE = 'en-US';
  const API = 'https://egs-platform-service.store.epicgames.com/api/v2/public/discover/home';

  const button = document.createElement('button');
  button.textContent = '生成 iOS + Android 购买链接';
  Object.assign(button.style, {
    position: 'fixed', right: '22px', bottom: '22px', zIndex: '2147483647',
    padding: '12px 16px', border: '0', borderRadius: '9px',
    background: '#0078f2', color: '#fff', fontSize: '14px', fontWeight: '700',
    boxShadow: '0 3px 14px #0005', cursor: 'pointer'
  });
  document.body.appendChild(button);

  const panel = document.createElement('div');
  Object.assign(panel.style, {
    position: 'fixed', right: '22px', bottom: '76px', zIndex: '2147483647',
    display: 'none', boxSizing: 'border-box', width: 'min(580px, calc(100vw - 32px))',
    padding: '14px', borderRadius: '9px', background: '#171717', color: '#fff',
    font: '13px/1.5 system-ui, sans-serif', boxShadow: '0 3px 18px #0007',
    overflowWrap: 'anywhere'
  });
  document.body.appendChild(panel);

  function showMessage(message, url = '') {
    panel.replaceChildren();
    const text = document.createElement('div');
    text.textContent = message;
    panel.appendChild(text);
    if (url) {
      const link = document.createElement('a');
      link.href = url;
      link.target = '_blank';
      link.rel = 'noopener noreferrer';
      link.textContent = url;
      Object.assign(link.style, { display: 'block', marginTop: '8px', color: '#8cc8ff' });
      panel.appendChild(link);
      const copyButton = document.createElement('button');
      copyButton.textContent = '再复制一次';
      Object.assign(copyButton.style, {
        marginTop: '10px', padding: '6px 10px', border: '0', borderRadius: '6px',
        cursor: 'pointer'
      });
      copyButton.addEventListener('click', () => GM_setClipboard(url));
      panel.appendChild(copyButton);
    }
    panel.style.display = 'block';
  }

  function requestJson(url) {
    return new Promise((resolve, reject) => {
      GM_xmlhttpRequest({
        method: 'GET', url, timeout: 25000,
        headers: { Accept: 'application/json', 'Cache-Control': 'no-cache' },
        onload: response => {
          if (response.status < 200 || response.status >= 300) {
            const detail = String(response.responseText || '').trim().replace(/\s+/g, ' ').slice(0, 280);
            reject(new Error(`Epic 移动商店接口返回 HTTP ${response.status}${detail ? `:${detail}` : ''}`));
            return;
          }
          try { resolve(JSON.parse(response.responseText)); }
          catch (error) { reject(new Error('接口返回的内容不是有效 JSON')); }
        },
        onerror: () => reject(new Error('请求 Epic 移动商店接口失败;请检查网络或稍后重试')),
        ontimeout: () => reject(new Error('请求超时,请稍后重试'))
      });
    });
  }

  function getBaseSlug(slug) {
    return String(slug || '')
      .replace(/-(android|ios)-[a-z0-9]{6}$/i, '')
      .replace(/-[a-z0-9]{6}$/i, '')
      .toLowerCase();
  }

  function normalize(value) {
    return String(value || '').toLocaleLowerCase().replace(/[^a-z0-9]+/g, '');
  }

  function getCurrentProduct() {
    const match = location.pathname.match(/\/p\/([^/]+)/i);
    if (!match) throw new Error('请先打开 Epic 商店的具体游戏商品页面。');
    const slug = decodeURIComponent(match[1]);
    const baseSlug = getBaseSlug(slug);
    const heading = document.querySelector('h1')?.innerText?.trim() ||
      document.title.replace(/\s*[|–—-]\s*Epic Games Store.*$/i, '').trim();
    const titleKeys = new Set([normalize(baseSlug.replace(/-/g, ' ')), normalize(heading)]);
    // Epic 的部分商品标题是“游戏名 - 副标题”;把各段作为精确候选,避免宽泛模糊匹配。
    for (const part of heading.split(/\s+[-–—:|]\s+/)) {
      const key = normalize(part);
      if (key.length >= 4) titleKeys.add(key);
    }
    return { slug, baseSlug, titleKeys, heading };
  }

  function flattenOffers(root) {
    const found = [];
    const seen = new Set();
    function visit(value) {
      if (!value || typeof value !== 'object' || seen.has(value)) return;
      seen.add(value);
      if (value.content && Array.isArray(value.content.purchase)) found.push(value);
      for (const child of Object.values(value)) visit(child);
    }
    visit(root);
    return found;
  }

  function findSlugs(root) {
    const slugs = [];
    const seen = new Set();
    function visit(value, key = '') {
      if (typeof value === 'string') {
        if (!/(slug|url|link|path|uri)/i.test(key)) return;
        const match = value.match(/\/p\/([^/?#]+)/i);
        if (match) slugs.push(decodeURIComponent(match[1]));
        else if (/slug/i.test(key) && /^[a-z0-9-]+$/i.test(value)) slugs.push(value);
        return;
      }
      if (!value || typeof value !== 'object' || seen.has(value)) return;
      seen.add(value);
      if (Array.isArray(value)) value.forEach(item => visit(item, key));
      else Object.entries(value).forEach(([childKey, child]) => visit(child, childKey));
    }
    visit(root);
    return slugs;
  }

  function extractMatches(json, product) {
    const all = flattenOffers(json);
    const byPurchase = new Map();
    for (const item of all) {
      const content = item.content || {};
      const names = [content.title, item.title].filter(Boolean).map(normalize);
      const slugMatch = findSlugs(item).some(slug => getBaseSlug(slug) === product.baseSlug);
      const titleMatch = names.some(name => product.titleKeys.has(name));
      if (!slugMatch && !titleMatch) continue;

      // 与开源 Epic 移动商店抓取器采用相同的 purchase[0] 规则,避免把同一页面中的
      // 其他购买类型误认为另一个商品版本。
      const purchases = content.purchase || [];
      const purchase = purchases.find(p => p?.purchasePayload?.sandboxId && p?.purchasePayload?.offerId);
      const payload = purchase?.purchasePayload;
      if (!payload) continue;
      const key = `${payload.sandboxId}:${payload.offerId}`;
      if (!byPurchase.has(key)) {
        byPurchase.set(key, {
          title: content.title || item.title || product.heading,
          sandboxId: payload.sandboxId,
          offerId: payload.offerId,
          slugMatch
        });
      } else if (slugMatch) {
        byPurchase.get(key).slugMatch = true;
      }
    }
    const matches = [...byPurchase.values()];
    // 若存在 URL/slug 的精确对应关系,优先忽略仅靠标题匹配到的相似条目。
    if (matches.some(match => match.slugMatch)) return matches.filter(match => match.slugMatch);
    return matches;
  }

  function warmUpEpicStore() {
    // 与已知可用的开源抓取器相同,先访问商店首页建立可能需要的站点会话。
    // 预热失败不直接中止;最终以 API 请求结果为准。
    return new Promise(resolve => {
      GM_xmlhttpRequest({
        method: 'GET', url: 'https://store.epicgames.com/', timeout: 12000,
        headers: { Accept: 'text/html,application/xhtml+xml', 'Accept-Language': LOCALE, 'Cache-Control': 'no-cache' },
        onload: () => resolve(), onerror: () => resolve(), ontimeout: () => resolve()
      });
    });
  }

  async function findPlatformOffer(platform, product) {
    // Epic 移动商店发现页接口使用 count=10;较大的 count 可能直接返回 HTTP 400。
    // 注意:该接口仅返回发现页内容,并非完整商品搜索接口。
    const query = new URLSearchParams({
      count: '10', country: COUNTRY, locale: LOCALE,
      platform, start: '0', store: 'EGS'
    });
    const json = await requestJson(`${API}?${query.toString()}`);
    const matches = extractMatches(json, product);
    if (matches.length === 0) {
      throw new Error(`${platform.toUpperCase()}:移动商店发现页返回的数据中没有找到与“${product.heading}”对应的商品。`);
    }
    if (matches.length > 1) {
      const list = matches.map(x => `${x.title} (${x.sandboxId}/${x.offerId})`).join('\n');
      throw new Error(`${platform.toUpperCase()}:匹配到多个不同商品,为避免生成错误链接,已停止:\n${list}`);
    }
    return matches[0];
  }

  button.addEventListener('click', async () => {
    button.disabled = true;
    button.textContent = '正在查询移动版本…';
    panel.style.display = 'none';
    try {
      const product = getCurrentProduct();
      await warmUpEpicStore();
      const [android, ios] = await Promise.all([
        findPlatformOffer('android', product),
        findPlatformOffer('ios', product)
      ]);
      const url = 'https://store.epicgames.com/purchase?' + [ios, android]
        .map(item => `offers=1-${item.sandboxId}-${item.offerId}`).join('&');
      GM_setClipboard(url);
      showMessage(`已复制 iOS + Android 购买链接。匹配到的商品:iOS「${ios.title}」;Android「${android.title}」。点击下方链接可打开购买页。`, url);
    } catch (error) {
      showMessage(`未能自动生成链接:${error.message}\n\n此脚本只查询 Epic 移动商店发现页返回的商品;若游戏未出现在该数据中,不能据此判断它没有移动版本。`);
    } finally {
      button.disabled = false;
      button.textContent = '生成 iOS + Android 购买链接';
    }
  });
})();

你这个和 pop 的有什么区别?而且还缺电脑游戏

(闭紧眼睛)我没看见,我啥也没看见,我溜了,晚上得去小青蛙家蹭饭,再不出门不赶趟了,就这样啊,拜拜……

这个可以一键同时领取安卓和iOS的