Skip to content

Commit 89b598f

Browse files
committed
Condensed api.createReqData()
1 parent b30d47a commit 89b598f

File tree

4 files changed

+40
-60
lines changed

4 files changed

+40
-60
lines changed

amazongpt/greasemonkey/amazongpt.user.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @description Adds the magic of AI to Amazon shopping
44
// @author KudoAI
55
// @namespace https://kudoai.com
6-
// @version 2025.1.25.12
6+
// @version 2025.1.25.13
77
// @license MIT
88
// @icon https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon48.png?v=0fddfc7
99
// @icon64 https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon64.png?v=0fddfc7
@@ -2504,32 +2504,27 @@
25042504

25052505
async createReqData(api, msgs) { // returns payload for POST / query string for GET
25062506
msgs = structuredClone(msgs) // avoid mutating global msgChain
2507-
let reqData ; const time = Date.now(), lastUserMsg = msgs[msgs.length - 1]
2507+
const time = Date.now(), lastUserMsg = msgs[msgs.length - 1]
25082508
lastUserMsg.content = prompts.augment(lastUserMsg.content, { api: api })
2509-
if (api == 'OpenAI') reqData = { messages: msgs, model: 'gpt-3.5-turbo', max_tokens: 4000 }
2510-
else if (api == 'AIchatOS')
2511-
reqData = {
2509+
const reqData = api == 'OpenAI' ? { messages: msgs, model: 'gpt-3.5-turbo', max_tokens: 4000 }
2510+
: api == 'AIchatOS' ? {
25122511
network: true, prompt: lastUserMsg.content,
25132512
userId: apis.AIchatOS.userID, withoutContext: false
2514-
}
2515-
else if (api == 'FREEGPT')
2516-
reqData = {
2513+
} : api == 'FREEGPT' ? {
25172514
messages: msgs, pass: null,
25182515
sign: await crypto.generateSignature({ time: time, msg: lastUserMsg.content, pkey: '' }),
25192516
time: time
2520-
}
2521-
else if (api == 'GPTforLove') {
2522-
reqData = {
2517+
} : api == 'GPTforLove' ? {
25232518
prompt: lastUserMsg.content, secret: session.generateGPTFLkey(),
25242519
systemMessage: 'You are ChatGPT, the version is GPT-4o, a large language model trained by OpenAI. '
25252520
+ 'Follow the user\'s instructions carefully. '
25262521
+ `${prompts.create('language', { mods: 'noChinese' })} `
25272522
+ `${prompts.create('humanity', { mods: 'all' })} `,
25282523
temperature: 0.8, top_p: 1
2529-
}
2530-
if (apis.GPTforLove.parentID) reqData.options = { parentMessageId: apis.GPTforLove.parentID }
2531-
} else if (api == 'MixerBox AI') reqData = { model: 'gpt-3.5-turbo', prompt: msgs }
2532-
else if (apis[api].method == 'GET') reqData = encodeURIComponent(lastUserMsg.content)
2524+
} : api == 'MixerBox AI' ? { model: 'gpt-3.5-turbo', prompt: msgs }
2525+
: apis[api].method == 'GET' ? encodeURIComponent(lastUserMsg.content) : null
2526+
if (api == 'GPTforLove' && apis.GPTforLove.parentID) // include parentID for contextual replies
2527+
reqData.options = { parentMessageId: apis.GPTforLove.parentID }
25332528
return typeof reqData == 'string' ? reqData : JSON.stringify(reqData)
25342529
},
25352530

bravegpt/greasemonkey/bravegpt.user.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
// @description:zu Yengeza izimpendulo ze-AI ku-Brave Search (inikwa amandla yi-GPT-4o!)
149149
// @author KudoAI
150150
// @namespace https://kudoai.com
151-
// @version 2025.1.25.13
151+
// @version 2025.1.25.14
152152
// @license MIT
153153
// @icon https://assets.bravegpt.com/images/icons/bravegpt/icon48.png?v=df624b0
154154
// @icon64 https://assets.bravegpt.com/images/icons/bravegpt/icon64.png?v=df624b0
@@ -3202,32 +3202,27 @@
32023202

32033203
async createReqData(api, msgs) { // returns payload for POST / query string for GET
32043204
msgs = structuredClone(msgs) // avoid mutating global msgChain
3205-
let reqData ; const time = Date.now(), lastUserMsg = msgs[msgs.length - 1]
3205+
const time = Date.now(), lastUserMsg = msgs[msgs.length - 1]
32063206
lastUserMsg.content = prompts.augment(lastUserMsg.content, { api: api })
3207-
if (api == 'OpenAI') reqData = { messages: msgs, model: 'gpt-3.5-turbo', max_tokens: 4000 }
3208-
else if (api == 'AIchatOS')
3209-
reqData = {
3207+
const reqData = api == 'OpenAI' ? { messages: msgs, model: 'gpt-3.5-turbo', max_tokens: 4000 }
3208+
: api == 'AIchatOS' ? {
32103209
network: true, prompt: lastUserMsg.content,
32113210
userId: apis.AIchatOS.userID, withoutContext: false
3212-
}
3213-
else if (api == 'FREEGPT')
3214-
reqData = {
3211+
} : api == 'FREEGPT' ? {
32153212
messages: msgs, pass: null,
32163213
sign: await crypto.generateSignature({ time: time, msg: lastUserMsg.content, pkey: '' }),
32173214
time: time
3218-
}
3219-
else if (api == 'GPTforLove') {
3220-
reqData = {
3215+
} : api == 'GPTforLove' ? {
32213216
prompt: lastUserMsg.content, secret: session.generateGPTFLkey(),
32223217
systemMessage: 'You are ChatGPT, the version is GPT-4o, a large language model trained by OpenAI. '
32233218
+ 'Follow the user\'s instructions carefully. '
32243219
+ `${prompts.create('language', { mods: 'noChinese' })} `
32253220
+ `${prompts.create('humanity', { mods: 'all' })} `,
32263221
temperature: 0.8, top_p: 1
3227-
}
3228-
if (apis.GPTforLove.parentID) reqData.options = { parentMessageId: apis.GPTforLove.parentID }
3229-
} else if (api == 'MixerBox AI') reqData = { model: 'gpt-3.5-turbo', prompt: msgs }
3230-
else if (apis[api].method == 'GET') reqData = encodeURIComponent(lastUserMsg.content)
3222+
} : api == 'MixerBox AI' ? { model: 'gpt-3.5-turbo', prompt: msgs }
3223+
: apis[api].method == 'GET' ? encodeURIComponent(lastUserMsg.content) : null
3224+
if (api == 'GPTforLove' && apis.GPTforLove.parentID) // include parentID for contextual replies
3225+
reqData.options = { parentMessageId: apis.GPTforLove.parentID }
32313226
return typeof reqData == 'string' ? reqData : JSON.stringify(reqData)
32323227
},
32333228

duckduckgpt/greasemonkey/duckduckgpt.user.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
// @description:zu Yengeza izimpendulo ze-AI ku-DuckDuckGo (inikwa amandla yi-GPT-4o!)
149149
// @author KudoAI
150150
// @namespace https://kudoai.com
151-
// @version 2025.1.25.14
151+
// @version 2025.1.25.15
152152
// @license MIT
153153
// @icon https://assets.ddgpt.com/images/icons/duckduckgpt/icon48.png?v=06af076
154154
// @icon64 https://assets.ddgpt.com/images/icons/duckduckgpt/icon64.png?v=06af076
@@ -3088,32 +3088,27 @@
30883088

30893089
async createReqData(api, msgs) { // returns payload for POST / query string for GET
30903090
msgs = structuredClone(msgs) // avoid mutating global msgChain
3091-
let reqData ; const time = Date.now(), lastUserMsg = msgs[msgs.length - 1]
3091+
const time = Date.now(), lastUserMsg = msgs[msgs.length - 1]
30923092
lastUserMsg.content = prompts.augment(lastUserMsg.content, { api: api })
3093-
if (api == 'OpenAI') reqData = { messages: msgs, model: 'gpt-3.5-turbo', max_tokens: 4000 }
3094-
else if (api == 'AIchatOS')
3095-
reqData = {
3093+
const reqData = api == 'OpenAI' ? { messages: msgs, model: 'gpt-3.5-turbo', max_tokens: 4000 }
3094+
: api == 'AIchatOS' ? {
30963095
network: true, prompt: lastUserMsg.content,
30973096
userId: apis.AIchatOS.userID, withoutContext: false
3098-
}
3099-
else if (api == 'FREEGPT')
3100-
reqData = {
3097+
} : api == 'FREEGPT' ? {
31013098
messages: msgs, pass: null,
31023099
sign: await crypto.generateSignature({ time: time, msg: lastUserMsg.content, pkey: '' }),
31033100
time: time
3104-
}
3105-
else if (api == 'GPTforLove') {
3106-
reqData = {
3101+
} : api == 'GPTforLove' ? {
31073102
prompt: lastUserMsg.content, secret: session.generateGPTFLkey(),
31083103
systemMessage: 'You are ChatGPT, the version is GPT-4o, a large language model trained by OpenAI. '
31093104
+ 'Follow the user\'s instructions carefully. '
31103105
+ `${prompts.create('language', { mods: 'noChinese' })} `
31113106
+ `${prompts.create('humanity', { mods: 'all' })} `,
31123107
temperature: 0.8, top_p: 1
3113-
}
3114-
if (apis.GPTforLove.parentID) reqData.options = { parentMessageId: apis.GPTforLove.parentID }
3115-
} else if (api == 'MixerBox AI') reqData = { model: 'gpt-3.5-turbo', prompt: msgs }
3116-
else if (apis[api].method == 'GET') reqData = encodeURIComponent(lastUserMsg.content)
3108+
} : api == 'MixerBox AI' ? { model: 'gpt-3.5-turbo', prompt: msgs }
3109+
: apis[api].method == 'GET' ? encodeURIComponent(lastUserMsg.content) : null
3110+
if (api == 'GPTforLove' && apis.GPTforLove.parentID) // include parentID for contextual replies
3111+
reqData.options = { parentMessageId: apis.GPTforLove.parentID }
31173112
return typeof reqData == 'string' ? reqData : JSON.stringify(reqData)
31183113
},
31193114

googlegpt/greasemonkey/googlegpt.user.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
// @description:zu Yengeza izimpendulo ze-AI ku-Google Search (inikwa amandla yi-Google Gemma + GPT-4o!)
150150
// @author KudoAI
151151
// @namespace https://kudoai.com
152-
// @version 2025.1.25.13
152+
// @version 2025.1.25.14
153153
// @license MIT
154154
// @icon https://assets.googlegpt.io/images/icons/googlegpt/black/icon48.png?v=59409b2
155155
// @icon64 https://assets.googlegpt.io/images/icons/googlegpt/black/icon64.png?v=59409b2
@@ -3383,32 +3383,27 @@
33833383

33843384
async createReqData(api, msgs) { // returns payload for POST / query string for GET
33853385
msgs = structuredClone(msgs) // avoid mutating global msgChain
3386-
let reqData ; const time = Date.now(), lastUserMsg = msgs[msgs.length - 1]
3386+
const time = Date.now(), lastUserMsg = msgs[msgs.length - 1]
33873387
lastUserMsg.content = prompts.augment(lastUserMsg.content, { api: api })
3388-
if (api == 'OpenAI') reqData = { messages: msgs, model: 'gpt-3.5-turbo', max_tokens: 4000 }
3389-
else if (api == 'AIchatOS')
3390-
reqData = {
3388+
const reqData = api == 'OpenAI' ? { messages: msgs, model: 'gpt-3.5-turbo', max_tokens: 4000 }
3389+
: api == 'AIchatOS' ? {
33913390
network: true, prompt: lastUserMsg.content,
33923391
userId: apis.AIchatOS.userID, withoutContext: false
3393-
}
3394-
else if (api == 'FREEGPT')
3395-
reqData = {
3392+
} : api == 'FREEGPT' ? {
33963393
messages: msgs, pass: null,
33973394
sign: await crypto.generateSignature({ time: time, msg: lastUserMsg.content, pkey: '' }),
33983395
time: time
3399-
}
3400-
else if (api == 'GPTforLove') {
3401-
reqData = {
3396+
} : api == 'GPTforLove' ? {
34023397
prompt: lastUserMsg.content, secret: session.generateGPTFLkey(),
34033398
systemMessage: 'You are ChatGPT, the version is GPT-4o, a large language model trained by OpenAI. '
34043399
+ 'Follow the user\'s instructions carefully. '
34053400
+ `${prompts.create('language', { mods: 'noChinese' })} `
34063401
+ `${prompts.create('humanity', { mods: 'all' })} `,
34073402
temperature: 0.8, top_p: 1
3408-
}
3409-
if (apis.GPTforLove.parentID) reqData.options = { parentMessageId: apis.GPTforLove.parentID }
3410-
} else if (api == 'MixerBox AI') reqData = { model: 'gpt-3.5-turbo', prompt: msgs }
3411-
else if (apis[api].method == 'GET') reqData = encodeURIComponent(lastUserMsg.content)
3403+
} : api == 'MixerBox AI' ? { model: 'gpt-3.5-turbo', prompt: msgs }
3404+
: apis[api].method == 'GET' ? encodeURIComponent(lastUserMsg.content) : null
3405+
if (api == 'GPTforLove' && apis.GPTforLove.parentID) // include parentID for contextual replies
3406+
reqData.options = { parentMessageId: apis.GPTforLove.parentID }
34123407
return typeof reqData == 'string' ? reqData : JSON.stringify(reqData)
34133408
},
34143409

0 commit comments

Comments
 (0)