GeminiBot commited on
Commit ·
02bd6b6
1
Parent(s): add57ca
Inject globals into eval scope to fix undefined document error
Browse files160 unmodified lines161162163164165166167168169170171172173174175176177178179180160 unmodified lines// 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)");}160 unmodified lines161162163164165166167168169170171172173174175176177160 unmodified lines// Immortal DOM patches (already applied above) are good.// Execute script directly in the window context// Explicitly define globals for the script scope to prevent 'undefined' errorsconst result = await mockWindow.eval(`var window = this;var document = this.document;var navigator = this.navigator;var screen = this.screen;${jsScript}`) as any;if (!result || !result.client_hashes) {throw new Error("Script executed but returned invalid result (no client_hashes)");}
src/duckai.ts+9-12