Commit ·
690837a
1
Parent(s): b01564f
random user agent
Browse files7 unmodified lines89101112131415166 unmodified lines1821831841851861871885 unmodified lines19419519619719819920045 unmodified lines24624724824925025125229 unmodified lines28228328428528628728868 unmodified lines35735835936036136236329 unmodified lines3933943953963973983997 unmodified linesDuckAIRequest,} from "./types";const userAgent = new UserAgent();// Rate limiting tracking with sliding windowinterface RateLimitInfo {requestTimestamps: number[]; // Array of request timestamps for sliding window166 unmodified lines}}private async getVQD(): Promise<VQDResponse> {const response = await fetch("https://duckduckgo.com/duckchat/v1/status", {headers: {accept: "*/*",5 unmodified lines"sec-fetch-mode": "cors","sec-fetch-site": "same-origin","x-vqd-accept": "1","User-Agent": userAgent.toString(),},referrer: "https://duckduckgo.com/",referrerPolicy: "origin",45 unmodified lines// Wait if rate limiting is neededawait this.waitIfNeeded();const vqd = await this.getVQD();const { window } = new JSDOM(`<html><body><script>window.hash = ${vqd.hash}</script></body></html>`,29 unmodified lines"sec-fetch-site": "same-origin","x-fe-version": "serp_20250401_100419_ET-19d438eb199b2bf7c300","x-vqd-4": vqd.vqd,"User-Agent": userAgent.toString(),"x-vqd-hash-1": btoa(JSON.stringify({server_hashes: hash.server_hashes,68 unmodified lines// Wait if rate limiting is neededawait this.waitIfNeeded();const vqd = await this.getVQD();const { window } = new JSDOM(`<html><body><script>window.hash = ${vqd.hash}</script></body></html>`,29 unmodified lines"sec-fetch-site": "same-origin","x-fe-version": "serp_20250401_100419_ET-19d438eb199b2bf7c300","x-vqd-4": vqd.vqd,"User-Agent": userAgent.toString(),"x-vqd-hash-1": btoa(JSON.stringify({server_hashes: hash.server_hashes,7 unmodified lines8910111213166 unmodified lines1801811821831841851865 unmodified lines19219319419519619719845 unmodified lines24424524624724824925025129 unmodified lines28128228328428528628768 unmodified lines35635735835936036136236336429 unmodified lines3943953963973983994007 unmodified linesDuckAIRequest,} from "./types";// Rate limiting tracking with sliding windowinterface RateLimitInfo {requestTimestamps: number[]; // Array of request timestamps for sliding window166 unmodified lines}}private async getVQD(userAgent: string): Promise<VQDResponse> {const response = await fetch("https://duckduckgo.com/duckchat/v1/status", {headers: {accept: "*/*",5 unmodified lines"sec-fetch-mode": "cors","sec-fetch-site": "same-origin","x-vqd-accept": "1","User-Agent": userAgent,},referrer: "https://duckduckgo.com/",referrerPolicy: "origin",45 unmodified lines// Wait if rate limiting is neededawait this.waitIfNeeded();const userAgent = new UserAgent().toString();const vqd = await this.getVQD(userAgent);const { window } = new JSDOM(`<html><body><script>window.hash = ${vqd.hash}</script></body></html>`,29 unmodified lines"sec-fetch-site": "same-origin","x-fe-version": "serp_20250401_100419_ET-19d438eb199b2bf7c300","x-vqd-4": vqd.vqd,"User-Agent": userAgent,"x-vqd-hash-1": btoa(JSON.stringify({server_hashes: hash.server_hashes,68 unmodified lines// Wait if rate limiting is neededawait this.waitIfNeeded();const userAgent = new UserAgent().toString();const vqd = await this.getVQD(userAgent);const { window } = new JSDOM(`<html><body><script>window.hash = ${vqd.hash}</script></body></html>`,29 unmodified lines"sec-fetch-site": "same-origin","x-fe-version": "serp_20250401_100419_ET-19d438eb199b2bf7c300","x-vqd-4": vqd.vqd,"User-Agent": userAgent,"x-vqd-hash-1": btoa(JSON.stringify({server_hashes: hash.server_hashes,
src/duckai.ts+9-8