zerun xiong 작성 댓글: A review on 喜加一에 대한 댓글 항목이 2026-06-30에 스팸 사유로 신고되었습니다.

zerun xiong차단됨님의 글:

修复了一下


// ==UserScript==
// @name 喜加一 - xiawanshe 新版页面修复
// @version 2026-06-30-fix
// @description 修复 xiawanshe.com 新版首页不再包含 #xijiayi/#current_free/.link 导致按钮不出现的问题
// @author xiawanshetudou / patched by Codex
// @match https://*.xiawanshe.com/*
// @match https://xiawanshe.com/*
// @match https://*.epicgames.com/*
// @match https://*.steampowered.com/*
// @license MIT
// @grant none
// @namespace http://tampermonkey.net/
// ==/UserScript==

(function () {
'use strict';

const XWS_ORIGINS = ['https://www.xiawanshe.com', 'https://xiawanshe.com'];
const INDEX_KEY = '_xws_xjy';
const API_URL = 'https://www.xiawanshe.com/api/v1/xijiayi';

function postToXws(message) {
if (!window.opener) return;
for (const origin of XWS_ORIGINS) {
window.opener.postMessage(message, origin);
}
}

function setLocalData(name, value) {
const expdate = new Date(Date.now() + 3 * 60 * 1000);
document.cookie = `${name}=${encodeURIComponent(value)}; expires=${expdate.toUTCString()}; path=/`;
localStorage.setItem(name, String(value));
}

function getLocalData(name) {
const found = document.cookie
.split(';')
.map(item => item.trim())
.find(item => item.startsWith(`${name}=`));
if (found) return decodeURIComponent(found.slice(name.length + 1));
return localStorage.getItem(name);
}

function parseIndex() {
const value = getLocalData(INDEX_KEY);
const idx = parseInt(value, 10);
return Number.isNaN(idx) ? -1 : idx;
}

function createResultModal(html) {
const old = document.getElementById('xijiayi-result-modal');
if (old) old.remove();

const modal = document.createElement('div');
modal.id = 'xijiayi-result-modal';
modal.style.cssText = [
'position:fixed',
'z-index:2147483647',
'inset:0',
'background:rgba(0,0,0,.42)',
'display:flex',
'align-items:center',
'justify-content:center',
'font-family:system-ui,-apple-system,BlinkMacSystemFont,"Microsoft YaHei",sans-serif'
].join(';');

const box = document.createElement('div');
box.style.cssText = [
'background:#fff',
'color:#111827',
'min-width:320px',
'max-width:min(720px,calc(100vw - 32px))',
'max-height:80vh',
'overflow:auto',
'padding:20px',
'border-radius:8px',
'box-shadow:0 16px 48px rgba(0,0,0,.25)'
].join(';');
box.innerHTML = `

领取结果

${html}`;

const btn = document.createElement('button');
btn.textContent = '确认';
btn.style.cssText = 'margin-top:14px;background:#2563eb;color:#fff;border:0;border-radius:6px;padding:8px 16px;cursor:pointer';
btn.onclick = () => modal.remove();

box.appendChild(btn);
modal.appendChild(box);
document.body.appendChild(modal);
}

function receiveStorePage() {
const url = new URL(location.href);
if (!window.opener) return;

window.addEventListener('message', event => {
if (!event.origin.includes('xiawanshe.com')) return;
const data = event.data || {};
if (data.new_url) location.href = data.new_url;
if (data.close) window.close();
});

let idx = parseInt(url.searchParams.get('index'), 10);
if (Number.isNaN(idx)) idx = -1;

if (url.searchParams.get('xijiayi')) {
setLocalData(INDEX_KEY, idx);
postToXws({ url: location.href, msg: '喜加一页面', idx: parseIndex() });
}

if (url.hostname.includes('steampowered')) {
handleSteam(url);
} else if (url.hostname.includes('epicgames')) {
handleEpic(url);
}
}

function handleSteam(url) {
if (!url.searchParams.get('xijiayi')) {
postToXws({ url: location.href, data: '领取完成', idx: parseIndex() });
return;
}

if (!document.getElementById('account_pulldown')) {
postToXws({
url: location.href,
data: '领取失败,Steam 未登录,请先登录 store.steampowered.com',
idx: parseIndex()
});
return;
}

let clicked = false;
for (const item of document.getElementsByClassName('game_purchase_action')) {
if (!item.textContent.includes('-100%')) continue;
const btn = item.querySelector('.btn_green_steamui.btn_medium, .btn_green_white_innerfade');
if (btn) {
btn.click();
clicked = true;
}
}

postToXws({
url: location.href,
data: clicked ? '已点击领取,请确认 Steam 页面结果' : '未找到免费领取按钮,可能已领取或页面结构变化',
idx: parseIndex()
});
}

function handleEpic(url) {
if (!url.searchParams.get('xijiayi')) return;

let ticks = 0;
const timer = setInterval(() => {
ticks += 1;

const wrapper = document.getElementById('dieselReactWrapper');
if (wrapper && wrapper.textContent.toLowerCase().includes('missing account id')) {
clearInterval(timer);
postToXws({
url: location.href,
data: '领取失败,Epic 未登录,请先登录 store.epicgames.com',
idx: parseIndex()
});
return;
}

const blocked = document.querySelector('.payment-blocked__container h2');
if (blocked) {
clearInterval(timer);
postToXws({ url: location.href, data: `领取失败,${blocked.textContent}`, idx: parseIndex() });
return;
}

const confirmBtn = document.querySelector('.payment-order-confirm__btn, button[type="submit"]');
if (confirmBtn) {
clearInterval(timer);
confirmBtn.click();
waitEpicResult(confirmBtn);
return;
}

if (ticks > 45) {
clearInterval(timer);
postToXws({
url: location.href,
data: '领取失败,未找到 Epic 下单按钮,可能页面结构变化或需要手动确认',
idx: parseIndex()
});
}
}, 1000);
}

function waitEpicResult(confirmBtn) {
let ticks = 0;
const timer = setInterval(() => {
ticks += 1;
if (confirmBtn && document.contains(confirmBtn)) confirmBtn.click();

const captcha = document.getElementById('h_captcha_challenge_checkout_free_prod');
if (captcha && ticks > 60) {
clearInterval(timer);
postToXws({ url: location.href, data: '存在验证码,可能未领取成功', idx: parseIndex() });
return;
}

const result = document.querySelector('.payment-alert__content');
if (result && result.textContent.trim()) {
clearInterval(timer);
postToXws({ url: location.href, data: `领取结果: ${result.textContent.trim()}`, idx: parseIndex() });
return;
}

if (ticks > 20) {
clearInterval(timer);
postToXws({ url: location.href, data: '领取完成,但不确定订单状态,请到 Epic 查看', idx: parseIndex() });
}
}, 1000);
}

function findGiftPanel() {
const headings = [...document.querySelectorAll('h1,h2,h3')];
const heading = headings.find(node => node.textContent.includes('喜加一'));
return heading ? heading.closest('section, aside, div') : document.body;
}

function ensureButton() {
if (!location.hostname.includes('xiawanshe.com')) return;
if (document.getElementById('xijiayi_btn')) return;
if (!document.body || !document.body.textContent.includes('喜加一')) return;

const panel = findGiftPanel();
const button = document.createElement('button');
button.id = 'xijiayi_btn';
button.textContent = '一键喜加一入库';
button.style.cssText = [
'display:block',
'margin:12px 24px 0',
'background:#2563eb',
'color:#fff',
'border:0',
'border-radius:6px',
'padding:8px 14px',
'font-size:13px',
'font-weight:700',
'cursor:pointer',
'box-shadow:0 6px 16px rgba(37,99,235,.25)'
].join(';');
button.addEventListener('click', startClaim);
panel.appendChild(button);
}

async function loadCurrentFreeGames() {
const response = await fetch(API_URL, { credentials: 'include' });
const payload = await response.json();
const games = payload && payload.data && Array.isArray(payload.data.current_free)
? payload.data.current_free
: [];
return games
.filter(game => game && game.link)
.map(game => ({
name: game.title || game.name || game.id || game.link,
url: game.link,
source: game.source || ''
}));
}

async function startClaim() {
const button = document.getElementById('xijiayi_btn');
if (button.dataset.doing === '1') return;
button.dataset.doing = '1';
button.textContent = '处理中...';

let games;
try {
games = await loadCurrentFreeGames();
} catch (error) {
button.dataset.doing = '0';
button.textContent = '一键喜加一入库';
alert(`获取喜加一失败:${error.message || error}`);
return;
}

if (!games.length) {
button.dataset.doing = '0';
button.textContent = '一键喜加一入库';
alert('当前没有可领取的喜加一游戏,或接口未返回领取链接');
return;
}

runQueue(games, () => {
button.dataset.doing = '0';
button.textContent = '一键喜加一入库';
});
}

function runQueue(games, done) {
let index = 0;
let childWindow = null;
const results = Object.fromEntries(games.map(game => [game.name, '未领取']));

function next() {
if (index >= games.length) {
if (childWindow && !childWindow.closed) {
const last = new URL(games[games.length - 1].url);
childWindow.postMessage({ close: 1 }, `${last.protocol}//${last.hostname}`);
}
done();
const html = Object.entries(results)
.map(([name, result]) => `

${escapeHtml(name)}:${escapeHtml(result)}

`)
.join('');
setTimeout(() => createResultModal(html), 800);
return;
}

const current = new URL(games[index].url);
current.searchParams.set('xijiayi', '1');
current.searchParams.set('index', String(index));

if (childWindow && !childWindow.closed) {
const previous = new URL(games[Math.max(0, index - 1)].url);
childWindow.postMessage({ new_url: current.toString() }, `${previous.protocol}//${previous.hostname}`);
return;
}

childWindow = window.open(
current.toString(),
'SmallWindow',
`width=1000,height=800,left=${(screen.width - 1000) / 2},top=${(screen.height - 800) / 2}`
);

if (!childWindow) {
done();
alert('请允许浏览器弹出式窗口,然后刷新页面重试');
}
}

window.addEventListener('message', event => {
if (!event.origin.includes('steampowered.com') && !event.origin.includes('epicgames.com')) return;
const data = event.data || {};
if (!data.data) return;

let newIndex = parseInt(data.idx, 10);
if (Number.isNaN(newIndex) || newIndex < 0) newIndex = index;
results[games[newIndex] ? games[newIndex].name : `第 ${newIndex + 1} 个游戏`] = data.data;
index = newIndex + 1;
next();
});

next();
}

function escapeHtml(value) {
return String(value)
.replaceAll('&', '&')
.replaceAll('<', '<')
.replaceAll('>', '>')
.replaceAll('"', '"')
.replaceAll("'", ''');
}

receiveStorePage();
ensureButton();
setInterval(ensureButton, 1000);
})();

zerun xiong차단됨 (신고된 사용자)의 활동:

이 신고는 관리자에 의해 인정되었습니다.

Blatant comment spam