fix: Multiple bug fixes and code cleanup
All checks were successful
build-and-push / lint (push) Successful in 8s
build-and-push / sonar (push) Successful in 21s
build-and-push / docker (push) Successful in 25s

- package.json: Add missing @eslint/js and globals devDependencies
- docker-entrypoint.sh: Fix X11 lock file name (.X1-lock → .X11-lock)
- epic-claimer-new.js: Use imported solveCloudflare/isCloudflareChallenge instead of duplicate implementations
- src/cloudflare.js: Fix solveCloudflare to use cfg.flaresolverr_url, remove unused imports
- epic-games.js: Remove unused code (getFreeGamesFromGraphQL, exchangeTokenForCookies, FREE_GAMES_QUERY, deviceAuthLoginSuccess variable)
- Run eslint --fix to clean up trailing spaces
This commit is contained in:
root 2026-03-08 13:58:57 +00:00
parent b14530537a
commit 48c861b3de
6 changed files with 166 additions and 174 deletions

View file

@ -164,67 +164,12 @@ const ensureLoggedIn = async (page, context) => {
}
};
const isChallenge = async () => {
const cfFrame = page.locator('iframe[title*="Cloudflare"], iframe[src*="challenges"]');
const cfText = page.locator('text=Verify you are human');
return await cfFrame.count() > 0 || await cfText.count() > 0;
};
// Use imported isCloudflareChallenge and solveCloudflare from src/cloudflare.js
const isChallenge = async () => await isCloudflareChallenge(page);
const solveCloudflareChallenge = async () => {
try {
console.log('🔍 Detecting Cloudflare challenge...');
// Check if FlareSolverr is available
const flaresolverrUrl = cfg.flaresolverr_url || 'http://localhost:8191/v1';
const healthResponse = await fetch(`${flaresolverrUrl}/health`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
});
if (!healthResponse.ok) {
console.warn('⚠️ FlareSolverr not available at', flaresolverrUrl);
return false;
}
// Send request to FlareSolverr
const response = await fetch(`${flaresolverrUrl}/request`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
cmd: 'request.get',
url: URL_CLAIM,
maxTimeout: 60000,
session: 'epic-games',
}),
});
const data = await response.json();
if (data.status !== 'ok') {
console.warn('FlareSolverr failed:', data.message);
return false;
}
const solution = data.solution;
// Apply cookies to the browser context
const cookies = solution.cookies.map(cookie => ({
name: cookie.name,
value: cookie.value,
domain: cookie.domain,
path: cookie.path || '/',
secure: cookie.secure,
httpOnly: cookie.httpOnly,
}));
await context.addCookies(cookies);
console.log('✅ Cloudflare challenge solved by FlareSolverr');
return true;
} catch (error) {
console.error('FlareSolverr error:', error.message);
return false;
}
const solution = await solveCloudflare(page, URL_CLAIM);
return solution !== null;
};
let loginAttempts = 0;