🔐 Implement robust session persistence to avoid 'are you human' captcha checks

- Add comprehensive session persistence with cookies, localStorage, and sessionStorage
- Implement stealth browser features to reduce bot detection
- Add smartLogin() method that prioritizes saved sessions over fresh logins
- Create session management utilities (refresh, clear, test validity)
- Update enhanced screenshot service to use session persistence
- Add comprehensive documentation and test script
- Support manual login fallback when captcha is encountered
- Sessions stored in .tradingview-session/ directory for Docker compatibility

This solves the captcha problem by avoiding repeated logins through persistent sessions.
This commit is contained in:
mindesbunister
2025-07-12 21:39:53 +02:00
parent 483d4c6576
commit cf58d41444
8 changed files with 976 additions and 26 deletions

View File

@@ -133,8 +133,15 @@ Return only the JSON object with your technical analysis.`
const json = match[0]
console.log('Raw JSON from AI:', json)
const result = JSON.parse(json)
console.log('Parsed result:', result)
let result
try {
result = JSON.parse(json)
console.log('Parsed result:', result)
} catch (parseError) {
console.error('Failed to parse JSON:', parseError)
console.error('Raw JSON that failed:', json)
return null
}
// Sanitize the result to ensure no nested objects cause React issues
const sanitizedResult = {
@@ -146,7 +153,7 @@ Return only the JSON object with your technical analysis.`
},
recommendation: result.recommendation || 'HOLD',
confidence: typeof result.confidence === 'number' ? result.confidence : 0,
reasoning: typeof result.reasoning === 'string' ? result.reasoning : String(result.reasoning || ''),
reasoning: typeof result.reasoning === 'string' ? result.reasoning : String(result.reasoning || 'Basic technical analysis'),
...(result.entry && { entry: result.entry }),
...(result.stopLoss && { stopLoss: result.stopLoss }),
...(result.takeProfits && { takeProfits: result.takeProfits }),