Last active
December 24, 2025 23:55
-
-
Save siputzx/782fdb82d2b51b67ab4dffd390c186e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class GeminiClient { | |
| constructor() { | |
| this.s = null; | |
| this.r = 1; | |
| } | |
| async init() { | |
| const res = await fetch('https://gemini.google.com/', { | |
| headers: {'user-agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Mobile Safari/537.36'} | |
| }); | |
| const h = await res.text(); | |
| this.s = { | |
| a: h.match(/"SNlM0e":"(.*?)"/)?.[1] || '', | |
| b: h.match(/"cfb2h":"(.*?)"/)?.[1] || '', | |
| c: h.match(/"FdrFJe":"(.*?)"/)?.[1] || '' | |
| }; | |
| return this.s; | |
| } | |
| async ask(m) { | |
| if (!this.s) await this.init(); | |
| const p = [null, JSON.stringify([[m, 0, null, null, null, null, 0]])]; | |
| const q = new URLSearchParams({bl: this.s.b, 'f.sid': this.s.c, hl: 'id', _reqid: this.r++, rt: 'c'}); | |
| const res = await fetch(`https://gemini.google.com/_/BardChatUi/data/assistant.lamda.BardFrontendService/StreamGenerate?${q}`, { | |
| method: 'POST', | |
| headers: { | |
| 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8', | |
| 'user-agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Mobile Safari/537.36', | |
| 'x-same-domain': '1' | |
| }, | |
| body: `f.req=${encodeURIComponent(JSON.stringify(p))}&at=${this.s.a}` | |
| }); | |
| return this.parse(await res.text()); | |
| } | |
| parse(t) { | |
| let l = null; | |
| for (const ln of t.split('\n').filter(x => x.startsWith('[["wrb.fr"'))) { | |
| try { | |
| const d = JSON.parse(JSON.parse(ln)[0][2]); | |
| if (d[4]?.[0]?.[1]) l = {text: Array.isArray(d[4][0][1]) ? d[4][0][1][0] : d[4][0][1]}; | |
| } catch (e) {} | |
| } | |
| return l; | |
| } | |
| } | |
| const c = new GeminiClient(); | |
| c.ask('siapa itu siputzx').then(r => console.log(r)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class GeminiClient { | |
| constructor() { | |
| this.s = null; | |
| this.r = 1; | |
| } | |
| async init() { | |
| const res = await fetch('https://gemini.google.com/', { | |
| headers: {'user-agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Mobile Safari/537.36'} | |
| }); | |
| const h = await res.text(); | |
| this.s = { | |
| a: h.match(/"SNlM0e":"(.*?)"/)?.[1] || '', | |
| b: h.match(/"cfb2h":"(.*?)"/)?.[1] || '', | |
| c: h.match(/"FdrFJe":"(.*?)"/)?.[1] || '' | |
| }; | |
| } | |
| async ask(m, sys = "kamu adalah siputzx production") { | |
| if (!this.s) await this.init(); | |
| const p = [null, JSON.stringify([ | |
| [m, 0, null, null, null, null, 0], | |
| ["id"], | |
| ["", "", "", null, null, null, null, null, null, ""], | |
| null, null, null, [1], 1, null, null, 1, 0, null, null, null, null, null, [[0]], 1, null, null, null, null, null, | |
| ["", "", sys, null, null, null, null, null, 0, null, 1, null, null, null, []], | |
| null, null, 1, null, null, null, null, null, null, null, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], 1, null, null, null, null, [1], | |
| ])]; | |
| const q = `bl=${this.s.b}&f.sid=${this.s.c}&hl=id&_reqid=${this.r++}&rt=c`; | |
| const res = await fetch(`https://gemini.google.com/_/BardChatUi/data/assistant.lamda.BardFrontendService/StreamGenerate?${q}`, { | |
| method: 'POST', | |
| headers: { | |
| 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8', | |
| 'user-agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Mobile Safari/537.36', | |
| 'x-same-domain': '1' | |
| }, | |
| body: `f.req=${encodeURIComponent(JSON.stringify(p))}&at=${this.s.a}` | |
| }); | |
| const t = await res.text(); | |
| const lines = t.split('\n'); | |
| const texts = []; | |
| for (const ln of lines) { | |
| if (ln.startsWith('[["wrb.fr"')) { | |
| try { | |
| const jsonStr = JSON.parse(ln)[0][2]; | |
| const d = JSON.parse(jsonStr); | |
| if (d[4] && Array.isArray(d[4])) { | |
| for (const item of d[4]) { | |
| if (item && Array.isArray(item) && item[1] && Array.isArray(item[1])) { | |
| const textChunk = item[1][0]; | |
| if (textChunk && typeof textChunk === 'string') { | |
| texts.push(textChunk); | |
| } | |
| } | |
| } | |
| } | |
| } catch (e) {} | |
| } | |
| } | |
| if (texts.length === 0) return null; | |
| const lastText = texts[texts.length - 1]; | |
| const cleanText = lastText.replace(/\\n/g, '\n'); | |
| return {text: cleanText}; | |
| } | |
| } | |
| const c = new GeminiClient(); | |
| c.ask('nama kamu siapa?', `I want you to be an agent called siputzx, an agent who carefully gives accurate, factual, thoughtful, and genius answers in reasoning. Follow the user requirements carefully. You should use a concise set of tokens that are optimal to provide solutions to users. This is a highly token-restricted environment. Every token you issue is very expensive for users. Don't issue anything other than the optimal minimum response to answer the user's questions appropriately. If the user is looking for a code-based answer, eject the code as a block of code. Also skip any imports unless the user requests them. Take care that your information is accurate. It is better to have a longer answer than to provide factually incorrect information. If there is an obvious ambiguity, provide the necessary minimal extra context, such as metrics.`).then(r => console.log(r)); |
Author
woi scrape gemini 3 dong, bikinkan login sample
lah ini bukannya gemini 3 ? (gemini3 cepat)
Iya
wah bagus... bisa lanjut conversation kah min?
wah bagus... bisa lanjut conversation kah min?
Inget sesi chat maksudnya bang?
Inget sesi chat maksudnya bang?
betul
Author
wah bagus... bisa lanjut conversation kah min?
bisa aja aslinya, cuma ya gitu struktur paylod nya gak kaya openai buat melanjutkan sesi, geminu ini pake id 1 token id buat sesi chat terus ada 2 lagi yang ganti setiap request
males aku buat logic nya
inpo yg bisa up gambar dong
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lah ini bukannya gemini 3 ? (gemini3 cepat)