GeminiBot commited on
Commit ·
add57ca
1
Parent(s): b3c25c2
Simplify eval context to fix undefined document error
Browse files149 unmodified lines150151152153154155156157158159160161162163164165166167168149 unmodified linesreturn "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";};// Ensure document is globally available for eval(mockWindow as any).document = mockWindow.document;const result = await mockWindow.eval(`(function() {const window = this;const document = this.document;${jsScript}}).call(window)`) as any;if (!result || !result.client_hashes) {throw new Error("Invalid Challenge Response");}result.client_hashes[0] = ua;149 unmodified lines150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181149 unmodified linesreturn "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";};// --- CONTEXT PREPARATION ---// Inject everything directly into the window context to avoid scope issuesmockWindow.document = mockWindow.document;mockWindow.window = mockWindow;mockWindow.self = mockWindow;mockWindow.parent = mockWindow;mockWindow.top = mockWindow;// Immortal DOM patches (already applied above) are good.// Execute script directly in the window context// We wrap it in a try-catch block INSIDE the eval to capture script errorsconst result = mockWindow.eval(`try {${jsScript}} catch(e) {console.error("Script Eval Error:", e);null;}`);if (!result || !result.client_hashes) {// If result is null, maybe the script put the result in a global variable?// Sometimes DDG scripts do that. Let's check window.result or similar if needed.// But for now, throw detailed errorthrow new Error("Script executed but returned invalid result (no client_hashes)");}result.client_hashes[0] = ua;
src/duckai.ts+23-10