♻️ refactor(code): remove unused code and clean up
Some checks failed
build-and-push / lint (push) Failing after 8s
build-and-push / sonar (push) Has been skipped
build-and-push / docker (push) Has been skipped

- remove unused screenshot helper function
- remove unnecessary empty arguments from launch options
- add spacing for readability in async functions
This commit is contained in:
nocci 2026-01-08 15:20:21 +00:00
parent 58282897b5
commit fd0fc4e981

View file

@ -19,9 +19,6 @@ const URL_CLAIM = 'https://store.epicgames.com/en-US/free-games';
const COOKIES_PATH = path.resolve(cfg.dir.browser, 'epic-cookies.json'); const COOKIES_PATH = path.resolve(cfg.dir.browser, 'epic-cookies.json');
const BEARER_TOKEN_NAME = 'EPIC_BEARER_TOKEN'; const BEARER_TOKEN_NAME = 'EPIC_BEARER_TOKEN';
// Screenshot Helper
const screenshot = (...a) => path.resolve(cfg.dir.screenshots, 'epic-games', ...a);
// Fetch Free Games from API // Fetch Free Games from API
const fetchFreeGamesAPI = async () => { const fetchFreeGamesAPI = async () => {
const resp = await axios.get('https://store-site-backend-static-ipv4.ak.epicgames.com/freeGamesPromotions', { const resp = await axios.get('https://store-site-backend-static-ipv4.ak.epicgames.com/freeGamesPromotions', {
@ -94,6 +91,7 @@ const getValidAuth = async ({ otpKey, reuseCookies, cookiesPath }) => {
console.log('🔐 Starting fresh OAuth device flow (manual approval required)...'); console.log('🔐 Starting fresh OAuth device flow (manual approval required)...');
let deviceResponse; let deviceResponse;
try { try {
deviceResponse = await axios.post('https://api.epicgames.dev/epic/oauth/deviceCode', { deviceResponse = await axios.post('https://api.epicgames.dev/epic/oauth/deviceCode', {
client_id: '34a02cf8f4414e29b159cdd02e6184bd', client_id: '34a02cf8f4414e29b159cdd02e6184bd',
@ -137,6 +135,7 @@ const ensureLoggedIn = async (page, context) => {
const attemptAutoLogin = async () => { const attemptAutoLogin = async () => {
if (!cfg.eg_email || !cfg.eg_password) return false; if (!cfg.eg_email || !cfg.eg_password) return false;
try { try {
await page.goto('https://www.epicgames.com/id/login?lang=en-US&noHostRedirect=true&redirectUrl=' + URL_CLAIM, { await page.goto('https://www.epicgames.com/id/login?lang=en-US&noHostRedirect=true&redirectUrl=' + URL_CLAIM, {
waitUntil: 'domcontentloaded', waitUntil: 'domcontentloaded',
@ -318,7 +317,6 @@ export const claimEpicGamesNew = async () => {
recordVideo: cfg.record ? { dir: 'data/record/', size: { width: cfg.width, height: cfg.height } } : undefined, recordVideo: cfg.record ? { dir: 'data/record/', size: { width: cfg.width, height: cfg.height } } : undefined,
recordHar: cfg.record ? { path: `data/record/eg-${filenamify(datetime())}.har` } : undefined, recordHar: cfg.record ? { path: `data/record/eg-${filenamify(datetime())}.har` } : undefined,
handleSIGINT: false, handleSIGINT: false,
args: [],
}); });
handleSIGINT(context); handleSIGINT(context);
await stealth(context); await stealth(context);