/g, "").replace(/<\/em>/g, "").replace(/\$\$(.*?)\$\$/g, (_, tex) => {
//debugger
return katex.renderToString(tex, {displayMode: false, throwOnError: false});
});
renderedHtml = renderedHtml.replace(/\$(.*?)\$/g, (_, tex) => {
//debugger
return katex.renderToString(tex, {displayMode: false, throwOnError: false});
});
// console.log("========katexTohtml end=======")
try {
renderedHtml = filterXSS(renderedHtml) //filterXSS
}catch (e) {
console.warn(e)
}
return renderedHtml;
}
function filterXSS(input) {
//let output = input.replace(/
let req1 = await GM_fetch({
method: "GET",
url: "https://xinghuo.xfyun.cn/chat",
headers: {
"origin":"https://xinghuo.xfyun.cn",
"referer":"https://xinghuo.xfyun.cn/"
}
})
let r = req1.responseText;
//console.log(r);
let mainjs;
try{
mainjs = /src="(\/static\/js\/main.*?.js)"/.exec(r)[1];//https://xinghuo.xfyun.cn/static/js/main.04f3ec36.js
console.log("mainjs:",mainjs)
}catch (e) {
console.error(r)
showAnserAndHighlightCodeStr("出错了,js获取失败")
}
if(mainjs){
console.log("https://xinghuo.xfyun.cn"+ mainjs.trim())
let req2 = await GM_fetch({
method: "GET",
url: "https://xinghuo.xfyun.cn"+ mainjs.trim(),
headers: {
"origin":"https://xinghuo.xfyun.cn",
"referer":"https://xinghuo.xfyun.cn/"
}
})
let rr = req2.responseText;
console.log(rr.substring(0,100))
try{
const re = /appId:"(.*?)"/gi;
let match;
while ((match = re.exec(rr)) !== null) {
console.log(match[1]);
sp_appId = match[1];
}
/*let index = rr.indexOf("appId");
if (index !== -1) {
let sp_appId = rr.substring(index, index + 10); // 指定文本
}*/
console.log("sp_appId:",sp_appId)
}catch (e) {
console.error(e)
showAnserAndHighlightCodeStr("出错了,sp_appId获取失败",)
}
}
}
setTimeout(()=>{
if(getGPTMode()==="SPARK"){
init_sp_appId()
}
})
async function init_sp_chatId() {
//https://xinghuo.xfyun.cn/iflygpt/u/chat-list/v1/create-chat-list
let req1 = await GM_fetch({
method: "POST",
url: "https://xinghuo.xfyun.cn/iflygpt/u/chat-list/v1/create-chat-list",
headers: {
"accept": "application/json, text/plain, */*",
"x-requested-with": "XMLHttpRequest",
"origin":"https://xinghuo.xfyun.cn",
"Content-Type":"application/json",
"referer":"https://xinghuo.xfyun.cn/desk"
},
data:"{}"
})
let r = req1.responseText;
try{
sp_chatId = JSON.parse(r).data.id;
console.log("sp_chatId:",sp_chatId)
}catch (e) {
console.error(r)
showAnserAndHighlightCodeStr("sp_chatId获取失败")
}
}
setTimeout(()=>{
if(getGPTMode()==="SPARK"){
init_sp_chatId()
}
},500)
async function get_sp_GtToken() {
return new Promise(async (resolve, reject) => {
//https://riskct.geetest.com/g2/api/v1/pre_load?client_type=h5&callback=geetest_时间戳
let timestamp = Date.now();
let req1 = await GM_fetch({
method: "GET",
url: `https://riskct.geetest.com/g2/api/v1/pre_load?client_type=h5&callback=geetest_${timestamp}`,
headers: {
"accept": "*/*",
"referer": "https://xinghuo.xfyun.cn/"
}
})
let r = req1.responseText;
console.log(r);
try {
let rr = r.replace(`geetest_${timestamp}(`,
"");
rr = rr.substring(0, rr.length - 1)
console.log("rr", rr)
let rj = JSON.parse(rr);
console.log("rj:");
console.log(rj);
//====
let config = {
appId: sp_appId,
js: rj.data.js,
staticPath: rj.data.staticPath,
gToken: rj.data.gToken
}
console.log("config")
console.log(config)
setTimeout(() => {
initGeeGuard(config, (gd) => {
console.log(gd)
if (gd.data.gee_token) {
sp_GtToken = gd.data.gee_token;
resolve(sp_GtToken)
}else{
reject("出错")
}
})
}, 500)
} catch (e) {
console.error(e)
setTimeout(init_sp_chatId)
reject("出错")
}
})
}
//解码
function decodeSpark(src) {
/*let rv = function(e) {
return e.replace(/[^A-Za-z0-9\+\/]/g, "")
}*/
let dv = function(e) {
//return Buffer.from(e, "base64").toString("utf8")
// 将 base64 编码的字符串转换为字节数组
const bytes = CryptoJS.enc.Base64.parse(e);
// 将字节数组转换为 UTF-8 字符串
return bytes.toString(CryptoJS.enc.Utf8);
}//等价BASE64解码 6KaB
/*let fv = function(e) {
return dv(function(e) {
return rv(e.replace(/[-_]/g, (function(e) {
return "-" == e ? "+" : "/"
}
)))
}(e))
};*/
return dv(src);
}
let spark_first = true;
async function SPARK(){
showAnserAndHighlightCodeStr("请稍后,第一次切换到该线路需要刷新页面,该线路为官网线路,使用前确保已经登录[讯飞星火](https://xinghuo.xfyun.cn/)")
await get_sp_GtToken()
console.log("sp_GtToken",sp_GtToken)
//重命名
if(spark_first){
let req1 = await GM_fetch({
method: "POST",
url: "https://xinghuo.xfyun.cn/iflygpt/u/chat-list/v1/rename-chat-list",
headers: {
"accept": "application/json, text/plain, */*",
"x-requested-with": "XMLHttpRequest",
"origin":"https://xinghuo.xfyun.cn",
"Content-Type":"application/json",
"referer":"https://xinghuo.xfyun.cn/desk"
},
data:JSON.stringify({
"chatListId": sp_chatId,
"chatListName": your_qus
})
})
let r = req1.responseText;
console.log("rename chat:",r)
spark_first = false;
}
//提问
let sendData = `------WebKitFormBoundaryAS7tSr3osJng5Nxk\r\nContent-Disposition: form-data; name=\"fd\"\r\n\r\n${sp_fd}\r\n------WebKitFormBoundaryAS7tSr3osJng5Nxk\r\nContent-Disposition: form-data; name=\"clientType\"\r\n\r\n2\r\n------WebKitFormBoundaryAS7tSr3osJng5Nxk\r\nContent-Disposition: form-data; name=\"chatId\"\r\n\r\n${sp_chatId}\r\n------WebKitFormBoundaryAS7tSr3osJng5Nxk\r\nContent-Disposition: form-data; name=\"text\"\r\n\r\n${your_qus}\r\n------WebKitFormBoundaryAS7tSr3osJng5Nxk\r\nContent-Disposition: form-data; name=\"GtToken\"\r\n\r\n${sp_GtToken}\r\n------WebKitFormBoundaryAS7tSr3osJng5Nxk--\r\n`;
GM_fetch({
method: 'POST',
url: 'https://xinghuo.xfyun.cn/iflygpt-chat/u/chat_message/chat',
headers: {
"Content-Type": "multipart/form-data; boundary=----WebKitFormBoundaryAS7tSr3osJng5Nxk",
"challenge": "undefined",
"seccode": "",
"validate": "undefined",
"accept": "text/event-stream",
"x-requested-with": "XMLHttpRequest",
"origin":"https://xinghuo.xfyun.cn",
"referer":"https://xinghuo.xfyun.cn/desk"
},
responseType: "stream",
data: sendData
}).then((stream)=> {
let reader = stream.response.getReader()
let ans = []
//let de = []
reader.read().then(function processText({done, value}) {
if (done) {
console.log("===done==")
//console.log(de)
return
}
let responseItem = new TextDecoder("utf-8").decode(value)
console.log(responseItem)
responseItem.split("\n").forEach(item=>{
try {
let ii = item.replace(/data:/gi,"").trim();
if(ii && ii !==""){
let chunk = decodeSpark(ii)
//de.push(item.replace(/data:/gi,"").trim())
ans.push(chunk)
showAnserAndHighlightCodeStr(ans.join(""))
}
}catch (ex){
console.error(item)
}
})
return reader.read().then(processText)
},function (reason) {
console.log(reason)
}).catch((ex)=>{
console.log(ex)
})
})
}
//星火相关====end=====
//天工 ----start--------
let tg_invite_Token;
let tg_token;
async function initTGtoken() {
if (location.href.includes("neice.tiangong.cn")) {
//"invite-token": "Bearer " + c("formNatureQueueWaitToken"),
tg_invite_Token = localStorage.getItem("formNatureQueueWaitToken");
//token: "Bearer " + c("formNatureResearchToken"),
tg_token = localStorage.getItem("formNatureResearchToken");
GM_setValue("tg_invite_Token", tg_invite_Token)
GM_setValue("tg_token", tg_token)
if(tg_invite_Token){
document.querySelector('div[class="title"]').innerText = `invite_Token获取成功:${tg_invite_Token}`
}else{
document.querySelector('div[class="title"]').innerText = `invite_Token获取失败,请再次刷新`
}
setTimeout(initTGtoken,5000)
} else {
tg_invite_Token = GM_getValue("tg_invite_Token")
tg_token = GM_getValue("tg_token")
}
}
setTimeout(initTGtoken)
//过时 {"code":60101,"code_msg":"当前使用授权已失效,请重新排队"}
//resp_data.invite_token
async function waitAccess() {
let req1 = await GM_fetch({
method: "POST",
url: "https://neice.tiangong.cn/api/v1/queue/waitAccess",
headers: {
"accept": "application/json, text/plain, */*",
"origin":"https://neice.tiangong.cn",
"invite-token": `Bearer null`,
"Content-Type":"application/json",
"token": `Bearer ${tg_token}`,
"device": "Web",
"referer":"https://neice.tiangong.cn/interlocutionPage"
},
data:JSON.stringify({
data:{
token: ""
}
})
})
let r = req1.responseText;
console.log(r)
return new Promise((resolve, reject) => {
try {
tg_invite_Token = JSON.parse(r).resp_data.invite_token;
GM_setValue("waitAccess tg_invite_Token",tg_invite_Token)
resolve("更新成功,请再次点击")
}catch (e) {
resolve("waitAccess 异常 请到官网获取token后刷新页面。[天工AI](https://neice.tiangong.cn/interlocutionPage)")
}
})
}
let tg_session_id;
let tg_msg_id;
let tg_first = true;
async function TIANGONG(){
showAnserAndHighlightCodeStr("请稍后...使用该线路,请确保已经登天工官网获取token后刷新页面。[天工AI](https://neice.tiangong.cn/interlocutionPage)")
console.log("tg_token:",tg_token)
console.log("tg_invite_Token:",tg_invite_Token)
if(!tg_invite_Token || !tg_token){
showAnserAndHighlightCodeStr("token错误了。请确保已经登天工官网获取token后刷新页面。[天工AI](https://neice.tiangong.cn/interlocutionPage)")
return
}
//校验
let req1 = await GM_fetch({
method: "POST",
url: "https://neice.tiangong.cn/api/v1/user/inviteVerify",
headers: {
"accept": "application/json, text/plain, */*",
"origin":"https://neice.tiangong.cn",
"invite-token": `Bearer ${tg_invite_Token}`,
"Content-Type":"application/json",
"token": `Bearer ${tg_token}`,
"device": "Web",
"referer":"https://neice.tiangong.cn/interlocutionPage"
},
data:JSON.stringify({
data:{}
})
})
let r = req1.responseText;
console.log(r)
if(r.includes("请重新排队")){
showAnserAndHighlightCodeStr("invite_Token失效。请至官网获取token后刷新页面。[天工AI](https://neice.tiangong.cn/interlocutionPage)")
/* let result = await waitAccess();
showAnserAndHighlightCodeStr(result)*/
initTGtoken()
return
}
//新会话
if(!tg_session_id || tg_first){
console.log("新会话")
let req1 = await GM_fetch({
method: "POST",
url: "https://neice.tiangong.cn/api/v1/session/newSession",
headers: {
"accept": "application/json, text/plain, */*",
"origin":"https://neice.tiangong.cn",
"invite-token": `Bearer ${tg_invite_Token}`,
"Content-Type":"application/json",
"token": `Bearer ${tg_token}`,
"device": "Web",
"referer":"https://neice.tiangong.cn/interlocutionPage"
},
data:JSON.stringify({
data:{
content: your_qus
}
})
})
let r = req1.responseText;
console.log(r)
let rj = JSON.parse(r);
tg_session_id = rj.resp_data.session_id
tg_msg_id = rj.resp_data.dialogue[rj.resp_data.dialogue.length - 1].message_id
console.log("tg_session_id:",tg_session_id)
console.log("tg_msg_idg:",tg_msg_id)
tg_first = false;
}else {
console.log("旧会话")
let req1 = await GM_fetch({
method: "POST",
url: "https://neice.tiangong.cn/api/v1/chat/chat",
headers: {
"accept": "application/json, text/plain, */*",
"origin":"https://neice.tiangong.cn",
"invite-token": `Bearer ${tg_invite_Token}`,
"Content-Type":"application/json",
"token": `Bearer ${tg_token}`,
"device": "Web",
"referer":"https://neice.tiangong.cn/interlocutionPage"
},
data:JSON.stringify({
data:{
content: your_qus,
session_id: tg_session_id
}
})
})
let r = req1.responseText;
console.log(r)
let rj = JSON.parse(r);
tg_msg_id = rj.resp_data.result_message.message_id
console.log("tg_msg_idg:",tg_msg_id)
}
//获取信息信息
for (let i = 0; i < 60; i++) {
let req2 = await GM_fetch({
method: "POST",
timeout: 3000,
url: "https://neice.tiangong.cn/api/v1/chat/getMessage",
headers: {
"accept": "application/json, text/plain, */*",
"origin":"https://neice.tiangong.cn",
"invite-token": `Bearer ${tg_invite_Token}`,
"Content-Type":"application/json",
"token": `Bearer ${tg_token}`,
"device": "Web",
"referer":"https://neice.tiangong.cn/interlocutionPage"
},
data:JSON.stringify({
"data": {
"message_id": tg_msg_id
}
})
})
let rr = req2.responseText;
console.log(rr)
let rj = JSON.parse(rr);
try {
if(rj.resp_data.result_message.content){
showAnserAndHighlightCodeStr(rj.resp_data.result_message.content)
}
if(rj.resp_data.result_message.status === 3){
break;
}
}catch (e) {}
await delay(1000)
}
}
//天工 ----end--------
//问心一言 ----start---
let yy_aisearch_id;
let yy_pvId;
let yy_sessionId;
async function initYiYAN(){
let req1 = await GM_fetch({
method: "GET",
url: `https://chat.baidu.com/?pcasync=pc&asyncRenderUrl=&passportStaticPage=https%3A%2F%2Fwww.baidu.com%2Fcache%2Fuser%2Fhtml%2Fv3Jump.html&from=pc_tab&word=${encodeURI(your_qus)}&source=pd_ic`,
headers: {
"accept": "*/*",
"origin":"https://www.baidu.com",
"referer":`https://www.baidu.com/`
},
data:JSON.stringify({
data:{}
})
})
let r = req1.responseText;
yy_aisearch_id = /"aisearch_id":"(.*?)"/i.exec(r)[1];
yy_pvId = /"pvId":"(.*?)"/i.exec(r)[1];
yy_sessionId = /"sessionId":"(.*?)"/i.exec(r)[1];
console.log("yy_aisearch_id:",yy_aisearch_id)
console.log("yy_pvId:",yy_pvId)
console.log("yy_sessionId:",yy_sessionId)
}
setTimeout(()=>{
if(getGPTMode() === 'YIYAN'){
initYiYAN()
}
})
async function YIYAN() {
showAnserAndHighlightCodeStr("请稍后...该线路为官网线路,使用该线路,请确保已经登百度账号,再刷新页面。[百度](https://www.baidu.com/)")
GM_fetch({
method: 'POST',
url: 'https://chat-ws.baidu.com/aichat/api/conversation',
headers: {
"origin":"https://www.baidu.com",
"referer":`https://www.baidu.com/`,
"Content-Type": "application/json",
"accept": "text/event-stream"
},
responseType: "stream",
data: JSON.stringify({
"message": {
"inputMethod": "keyboard",
"isRebuild": false,
"content": {
"query": your_qus,
"qtype": 0
}
},
"sessionId": yy_sessionId,
"aisearchId": yy_aisearch_id,
"pvId": yy_pvId
})
}).then((stream)=> {
let reader = stream.response.getReader()
let ans = []
let preResponseItem = '';//前一记录
let combineItem = [];//合并
let referenceList;//引用
reader.read().then(function processText({done, value}) {
if (done) {
console.log("===done==")
//console.log(de)
let result = ans.join("");
let arr = result.match(/\^(.*?)\^/g);
let oldArr = arr.slice()
if(referenceList && referenceList.length > 0){
for (let i = 0; i < arr.length; i++) {
for (let j = 0; j < referenceList.length; j++) {
if(arr[i].includes(`[${j+1}]`)){
let url = referenceList[j].url;
arr[i] = arr[i].replace(`[${j+1}]`,`[${j+1}](${url})`)
}
}
}
}
console.log("arr:",arr)
console.log("oldArr:",oldArr)
for (let i = 0; i < oldArr.length; i++) {
result = result.replace(oldArr[i],arr[i].replace(/\^/g,""))
}
showAnserAndHighlightCodeStr(result)
return
}
let responseItem = new TextDecoder("utf-8").decode(value)
console.log(responseItem)
if(!responseItem.includes("event:ping") && !responseItem.startsWith("event:messag")){
combineItem.push(preResponseItem)
combineItem.push(responseItem)
preResponseItem = '';//恢复初始
responseItem = combineItem.join("")//合并
console.log("combineItem:",responseItem)
combineItem = [];//清空
}else if(!responseItem.includes("event:ping")){
preResponseItem = responseItem;
}
responseItem.split("\n").forEach(item=>{
try {
let ii = item.replace(/data:/gi,"").trim();
if(ii && ii !==""){
let chunk = JSON.parse(ii).data.message.content.generator.text
//de.push(item.replace(/data:/gi,"").trim())
ans.push(chunk)
showAnserAndHighlightCodeStr(ans.join(""))
if(JSON.parse(ii).data.message.content.generator.referenceList){
referenceList = JSON.parse(ii).data.message.content.generator.referenceList
}
}
}catch (ex){
console.error(item)
}
})
return reader.read().then(processText)
},function (reason) {
console.log(reason)
}).catch((ex)=>{
console.log(ex)
})
})
}
//问心一言 ----end---
let pizzaSecret;
async function setPizzakey() {
try {
let source = await GM_fetch({
method: "GET",
nocache: true,
url: "https://www.pizzagpt.it/",
headers: {
"Referer": `www.pizzagpt.it`
}
})
console.log(source)
let reqJS = source.responseText.match("index.*?\.js")[0];
GM_fetch({
method: "GET",
nocache: true,
synchronous: true,
url: "https://www.pizzagpt.it/_nuxt/" + reqJS.trim(),
headers: {
//"Content-Type": "application/json",
"Referer": `www.pizzagpt.it`
}
}).then((response)=> {
let resp = response.responseText;
pizzaSecret = resp.match("x=\"(.*?)\"")[1]
console.log("pizzaSecret:", pizzaSecret)
}).catch((e) => {
console.log(e)
})
} catch (e) {
console.log(e)
}
}
setTimeout(setPizzakey);
function PIZZA() {
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "https://www.pizzagpt.it/api/chat-completion",
headers: {
"Content-Type": "text/plain;charset=UTF-8",
"Referer": `https://www.pizzagpt.it/`
},
data: JSON.stringify({
question: your_qus,
secret: pizzaSecret
}),
onload: function (res) {
if (res.status === 200) {
console.log('成功....')
console.log(res)
let rest = res.responseText
//console.log(rest.choices[0].text.replaceAll("\n",""))
try {
showAnserAndHighlightCodeStr(JSON.parse(rest).answer.content)
} catch (e) {
//TODO handle the exception
console.log(e)
document.getElementById('gptAnswer').innerHTML = rest
}
} else {
console.log('失败')
console.log(res)
document.getElementById('gptAnswer').innerHTML = '访问失败了'
}
},
responseType: "text",
onerror: function (err) {
console.error(err)
showAnserAndHighlightCodeStr("出错,[访问](https://www.pizzagpt.it/)")
}
});
}
function PHIND() {
GM_xmlhttpRequest({
method: "POST",
url: "https://www.phind.com/api/web/search",
headers: {
"Content-Type": "application/json",
"Referer": `https://www.phind.com`
},
data: JSON.stringify({
"q": your_qus,
"userRankList": {},
"browserLanguage": "zh-CN"
}),
onload: function (res) {
if (res.status === 200) {
console.log('成功....')
console.log(res)
let rest = res.responseText
//console.log(rest.choices[0].text.replaceAll("\n",""))
let rjson = JSON.parse(rest);
let _bingResults = rjson.processedBingResults;
console.log(_bingResults)
GM_xmlhttpRequest({
method: "POST",
url: "https://www.phind.com/api/infer/answer",
headers: {
"Content-Type": "application/json",
"Referer": "https://www.phind.com/",
"accept": "*/*"
},
data: JSON.stringify({
"question": your_qus,
"bingResults": _bingResults,
"codeContext": "",
"options": {
"skill": "intermediate",
"date": formatTime(),
"language": "zh-CN",
"detailed": true,
"creative": false
}
}),
onloadstart: (stream) => {
let result = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
let finalResult = result.join("")
try {
console.log(finalResult)
showAnserAndHighlightCodeStr(finalResult)
} catch (e) {
console.log(e)
}
return;
}
try {
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
console.log(d)
let dd = d.replace(/data: /g, "").split("\r\n\r\n")
console.log("dd:",dd)
dd.forEach(item=>{
try {
result.push(item)
showAnserAndHighlightCodeStr(result.join(""))
}catch (e) {
}
})
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},
responseType: "stream",
onprogress: function (msg) {
//console.log(msg)
},
onerror: function (err) {
console.log(err)
},
ontimeout: function (err) {
console.log(err)
}
});
} else {
console.log('失败')
console.log(res)
showAnserAndHighlightCodeStr('访问失败了,[phind](https://www.phind.com/api/web/search)')
}
},
responseType: "application/json;charset=UTF-8",
onerror: function (err) {
document.getElementById('gptAnswer').innerHTML =
`some err happends,errinfo :
${err.messages}
`
}
});
}
function WOBCW() {
GM_xmlhttpRequest({
url: "https://chat.wobcw.com/chat",
headers: {
"accept": "*/*",
"referrer": "https://chat.wobcw.com/",
"content-type": "multipart/form-data; boundary=----WebKitFormBoundarybrMK1QixymFcNJzK"
},
data: `------WebKitFormBoundarybrMK1QixymFcNJzK\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\n${your_qus}\r\n------WebKitFormBoundarybrMK1QixymFcNJzK\r\nContent-Disposition: form-data; name=\"regen\"\r\n\r\nfalse\r\n------WebKitFormBoundarybrMK1QixymFcNJzK--\r\n`,
method: "POST",
onload: (resp) => {
let rs = resp.responseText;
console.log(rs)
let chat_id = JSON.parse(rs).chat_id;
console.log(chat_id)
abortXml = GM_xmlhttpRequest({
method: "GET",
url: `https://chat.wobcw.com/stream?chat_id=${chat_id}&api_key=`,
headers: {
"Content-Type": "application/json",
// "Authorization": "Bearer null",
"Referer": "https://chat.wobcw.com/",
//"Host":"www.aiai.zone",
"accept": "text/event-stream"
},
onloadstart: (stream) => {
let result = [];
let finalResult = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
finalResult = result.join("")
showAnserAndHighlightCodeStr(finalResult)
return;
}
try {
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
console.log("raw:",d)
let dd = d.replace(/data: /g, "").split("\n\n")
console.log("dd:",dd)
dd.forEach(item=>{
try {
let delta = JSON.parse(item).choices[0].delta.content
result.push(delta)
showAnserAndHighlightCodeStr(result.join(""))
}catch (e) {
}
})
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
showAnserAndHighlightCodeStr("erro:", err)
}
})
}//end onload
})
}
let parentID_tianhu;
let tianhu_first = true;
function AITIANHU() {
let ops = {};
if (parentID_tianhu) {
ops = {parentMessageId: parentID_tianhu};
}
console.log(ops)
if (tianhu_first) {
GM_xmlhttpRequest({
method: "POST",
synchronous: true,
url: "https://www.aitianhu.com/api/session",
headers: {
"Content-Type": "application/json",
"Referer": "https://www.aitianhu.com/",
"origin": "https://www.aitianhu.com",
"accept": "application/json, text/plain, */*"
},
onload: function (res) {
console.log(res)
}
})
tianhu_first = false;
}
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "https://www.aitianhu.com/api/chat-process",
headers: {
"Content-Type": "application/json",
"Referer": "https://www.aitianhu.com/",
"origin": "https://www.aitianhu.com",
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
top_p: 1,
prompt: your_qus,
systemMessage: "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.",
temperature: 0.8,
options: ops
}),
onloadstart: (stream) => {
let result = "";
const reader = stream.response.getReader();
// console.log(reader.read)
let finalResult;
reader.read().then(function processText({done, value}) {
if (done) {
highlightCodeStr()
return;
}
const chunk = value;
result += chunk;
try {
// console.log(normalArray)
let byteArray = new Uint8Array(chunk);
let decoder = new TextDecoder('utf-8');
console.log(decoder.decode(byteArray))
let jsonLines = decoder.decode(byteArray).split("\n");
let nowResult = JSON.parse(jsonLines[jsonLines.length - 1])
if (nowResult.text) {
console.log(nowResult)
finalResult = nowResult.text
showAnserAndHighlightCodeStr(finalResult)
}
if (nowResult.id) {
parentID_tianhu = nowResult.id;
}
} catch (e) {
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
showAnserAndHighlightCodeStr("erro:", err)
}
})
}
let parentID_anzz;
function authAnzz(){
console.log("authANZZ")
GM_fetch({
method: "POST",
url: "https://free.anzz.top/api/session",
headers: {
"Content-Type": "application/json",
"Referer": `https://free.anzz.top/`
},
data: JSON.stringify({})
}).then((res)=>{
console.log(res)
}).catch((ex)=>{
console.log(ex)
})
}
setTimeout(authAnzz);
function ANZZ() {
let ops = {};
if (parentID_anzz) {
ops = {parentMessageId: parentID_anzz};
}
console.log(ops)
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "https://free.anzz.top/api/chat-process",
headers: {
"Content-Type": "application/json",
"Referer": "https://free.anzz.top/",
"origin": "https://free.anzz.top",
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
top_p: 1,
prompt: your_qus,
systemMessage: "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.",
temperature: 0.8,
options: ops
}),
onloadstart: (stream) => {
let result = "";
const reader = stream.response.getReader();
// console.log(reader.read)
let finalResult;
reader.read().then(function processText({done, value}) {
if (done) {
highlightCodeStr()
return;
}
const chunk = value;
result += chunk;
try {
let byteArray = new Uint8Array(chunk);
let decoder = new TextDecoder('utf-8');
console.log(decoder.decode(byteArray))
let nowResult = JSON.parse(decoder.decode(byteArray))
if (nowResult.text) {
console.log(nowResult)
finalResult = nowResult.text
showAnserAndHighlightCodeStr(finalResult.replace(/hello-ai.anzz.top/gi,""))
}
if (nowResult.id) {
parentID_anzz = nowResult.id;
}
} catch (e) {
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
showAnserAndHighlightCodeStr("erro:", err)
}
})
}
let parentID_hhw;
function HEHANWANG() {
let ops = {};
if (parentID_hhw) {
ops = {parentMessageId: parentID_hhw};
}
console.log(ops)
GM_fetch({
method: "POST",
url: "https://chat1.hehanwang.com/api/chat-process",
headers: {
"Content-Type": "application/json",
"Referer": "https://chat1.hehanwang.com/",
"Authorization": "Bearer 293426",
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
top_p: 1,
prompt: your_qus,
systemMessage: "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.",
temperature: 0.8,
options: ops
}),
responseType: "stream"
}).then((stream) => {
let result = "";
const reader = stream.response.getReader();
// console.log(reader.read)
let finalResult;
reader.read().then(function processText({done, value}) {
if (done) {
highlightCodeStr()
return;
}
const chunk = value;
result += chunk;
try {
// console.log(normalArray)
let byteArray = new Uint8Array(chunk);
let decoder = new TextDecoder('utf-8');
console.log(decoder.decode(byteArray))
let jsonLines = decoder.decode(byteArray).split("\n");
let nowResult = JSON.parse(jsonLines[jsonLines.length - 1])
if (nowResult.text) {
console.log(nowResult)
finalResult = nowResult.text
showAnserAndHighlightCodeStr(finalResult)
}
if (nowResult.id) {
parentID_hhw = nowResult.id;
}
} catch (e) {
}
return reader.read().then(processText);
});
},(reason)=>{
console.log(reason)
}).catch((ex)=>{
console.log(ex)
});
}
let messageChain7 = [];//CHATDDD
function CHATDDD() {
let baseURL = "https://chatgptdddd.com/";
addMessageChain(messageChain7, {role: "user", content: your_qus})//连续话
GM_fetch({
method: "POST",
url: baseURL + "api/chat",
headers: {
"Content-Type": "application/json",
"Referer": baseURL
},
data: JSON.stringify({
messages: messageChain7,
model: {
"id": "gpt-3.5-turbo",
"name": "GPT-3.5",
"maxLength": 12000,
"tokenLimit": 4000
},
temperature: 1,
prompt: "你是 ChatGPT,一个由 OpenAI 训练的大型语言模型。你可以回答各种问题,帮助人们解决问题。 please think in english and answer by chinese",
key: null
}),
responseType: "stream"
}).then((stream) => {
let result = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
let finalResult = result.join("")
try {
console.log(finalResult)
addMessageChain(messageChain7, {
role: "assistant",
content: finalResult
})
showAnserAndHighlightCodeStr(finalResult)
} catch (e) {
console.log(e)
}
return;
}
try {
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
result.push(d)
showAnserAndHighlightCodeStr(result.join(""))
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
},function (reason) {
console.log(reason)
}).catch((ex)=>{
console.log(ex)
});
});
}
//https://gpt.esojourn.org/api/chat-stream https://0505.betai55.uk/api/chat-stream
function ESO() {
let baseURL = "https://gpt.esojourn.org/";
addMessageChain(messageChain4, {role: "user", content: your_qus})//连续话
GM_xmlhttpRequest({
method: "POST",
url: baseURL + "api/chat-stream",
headers: {
"Content-Type": "application/json",
"access-code": "586-481-535C",
"path": "v1/chat/completions",
"Referer": baseURL
},
data: JSON.stringify({
messages: messageChain4,
stream: true,
model: "gpt-3.5-turbo",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0
}),
onloadstart: (stream) => {
let result = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
let finalResult = result.join("")
try {
console.log(finalResult)
addMessageChain(messageChain4, {
role: "assistant",
content: finalResult
})
showAnserAndHighlightCodeStr(finalResult)
} catch (e) {
console.log(e)
}
return;
}
try {
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
result.push(d)
showAnserAndHighlightCodeStr(result.join(""))
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
}
});
}
function XCBL() {
//同LBB
let baseURL = "https://52221239187007.ai003.live/";
addMessageChain(messageChain5, {role: "user", content: your_qus})//连续话
GM_fetch({
method: "POST",
url: baseURL + "api/chat-stream",
headers: {
"Content-Type": "application/json",
"path": "v1/chat/completions",
"Referer": baseURL,
"origin": "https://52221239187007.ai003.live"
},
data: JSON.stringify({
messages: messageChain5,
stream: true,
model: "gpt-3.5-turbo",
temperature: 1,
presence_penalty: 0
}),
responseType: "stream"
}).then((stream) => {
let result = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
let finalResult = result.join("")
try {
console.log(finalResult)
addMessageChain(messageChain5, {
role: "assistant",
content: finalResult
})
showAnserAndHighlightCodeStr(finalResult)
} catch (e) {
console.log(e)
}
return;
}
try {
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
result.push(d)
showAnserAndHighlightCodeStr(result.join(""))
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},function (err) {
console.log(err)
}).catch((ex)=>{
console.log(ex)
})
}
//https://ai1.chagpt.fun/
function CVEOY() {
let baseURL = "https://free-api.cveoy.top/";
GM_xmlhttpRequest({
method: "POST",
url: baseURL + "v3/completions",
headers: {
"Content-Type": "application/json",
"origin": "https://ai1.chagpt.fun",
"Referer": baseURL
},
data: JSON.stringify({
prompt: your_qus
}),
onloadstart: (stream) => {
let result = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
try {
let finalResult = result.join("")
console.log(finalResult)
showAnserAndHighlightCodeStr(finalResult)
} catch (e) {
console.log(e)
}
return;
}
try {
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
if(d.match(/wxgpt@qq.com/gi)){
d = d.replace(/wxgpt@qq.com/gi,"")
}
result.push(d);
console.log(d)
showAnserAndHighlightCodeStr(result.join(""))
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
}
});
}
let parentID_extkj;
function EXTKJ() {
let ops = {};
if (parentID_extkj) {
ops = {parentMessageId: parentID_extkj};
}
console.log(ops)
let pt = CryptoJS.AES.encrypt(JSON.stringify(your_qus), "__CRYPTO_SECRET__I>EO)$__M*&.fsee").toString()
console.log("aes:" + pt)
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "https://chat.extkj.cn/api/chat-stream",
headers: {
"Content-Type": "application/json",
"Referer": "https://chat.extkj.cn/",
"origin": "https://chat.extkj.cn",
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
prompt: pt,
options: ops,
systemMessage: `You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.`
}),
onloadstart: (stream) => {
let result = "";
const reader = stream.response.getReader();
let finalResult = [];
reader.read().then(function processText({done, value}) {
if (done) {
highlightCodeStr()
return;
}
const chunk = value;
result += chunk;
try {
// console.log(normalArray)
let byteArray = new Uint8Array(chunk);
let decoder = new TextDecoder('utf-8');
console.log(decoder.decode(byteArray))
let nowResult = decoder.decode(byteArray)
if (nowResult) {
let jsonLine = nowResult.split("\n");
let jsonObj = JSON.parse(jsonLine[jsonLine.length - 1]);
finalResult = jsonObj.text;
if (jsonObj.id) {
parentID_extkj = jsonObj.id;
}
showAnserAndHighlightCodeStr(finalResult)
}
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
}
})
}
//4-25
function LBB() {
let baseURL = "https://43207713129.ai006.live/";
addMessageChain(messageChain8, {role: "user", content: your_qus})//连续话
GM_fetch({
method: "POST",
url: baseURL + "api/chat-stream",
headers: {
"Content-Type": "application/json",
"accept": "*/*",
"path": "v1/chat/completions",
"Referer": baseURL
},
data: JSON.stringify({
messages: messageChain8,
stream: true,
model: "gpt-3.5-turbo",
temperature: 1,
presence_penalty: 0
})
}).then((res)=>{
if (res.status === 200) {
console.log(res)
let rest = res.responseText
try {
addMessageChain(messageChain8, {
role: "assistant",
content: rest
})
showAnserAndHighlightCodeStr(rest);
} catch (ex) {
console.log(ex)
showAnserAndHighlightCodeStr(rest);
}
} else {
showAnserAndHighlightCodeStr('访问失败了');
}
},reason => {
console.log(reason)
}).catch((ex)=>{
console.log(ex)
})
}
// http://easyai.one
let sessionId_easyai = generateRandomString(20);
let easyai_ip = generateRandomIP();
function EASYAI() {
console.log(sessionId_easyai)
abortXml = GM_xmlhttpRequest({
method: "POST",
url: `https://ai.pp2pdf.com/easyapi/v1/chat/completions?message=${encodeURI(your_qus)}&sessionId=${sessionId_easyai}`,
headers: {
"Referer": "https://ai.pp2pdf.com/chat",
"X-Forwarded-For": easyai_ip,
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJvcGVuSWQiOiJvUElXOTV6bmJhTnlKa3RUalgza3BBcy1EOFJBIiwiZXhwIjoxNjg0MTM4MTI4LCJ1c2VySWQiOjEzNTV9.PdO-9ozH4aixDYifAt4hnSMkb8WfZmcHw-dZY_1eQ8g",
"accept": "text/event-stream"
},
onloadstart: (stream) => {
let finalResult = []
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
showAnserAndHighlightCodeStr(finalResult.join(""))
return;
}
try {
// console.log(normalArray)
let byteArray = new Uint8Array(value);
let decoder = new TextDecoder('utf-8');
console.log(decoder.decode(byteArray))
let regx = /\{\"content\":\"(.*?)\"\}/g;
let nowResult = regx.exec(decoder.decode(byteArray))[1]
console.log(nowResult)
finalResult.push(nowResult)
showAnserAndHighlightCodeStr(finalResult.join(""))
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
showAnserAndHighlightCodeStr("erro:", err)
}
})
}
//获取A类网站key 2023年5月3日
async function setNormalKey(url) {
let response = await GM_fetch({
method: "GET",
url: url,
headers: {
"Referer": url,
"origin": url
}
});
let resp = response.responseText;
let regex = /component-url="(.*?)"/i;
let match = resp.match(regex);
let jsurl = match[1];
console.log("js url:" + jsurl);
if (!jsurl) {
//错误
console.log(resp)
return
}
let rr = await GM_fetch({
method: "GET",
url: url + jsurl,
headers: {
"Referer": url,
"origin": url
}
});
resp = rr.responseText;
regex = /\`\$\{\w\}:\$\{\w\}:(.*?)\`/i;
match = resp.match(regex);
let key = match[1];
console.log(url+":key:",key)
return key
}
let bnuKey;
let bnuInt = localStorage.getItem("bnuInt") || Math.floor(Math.random() * 7);
setTimeout(async () => {
bnuKey = await setNormalKey(`https://chat.${bnuInt}.bnu120.space`);
});
//https://ic.muspimerol.site/
function BNU120() {
let now = Date.now();
let Baseurl = `https://chat.${bnuInt}.bnu120.space/`
generateSignatureWithPkey({
t: now,
m: your_qus || "",
pkey: bnuKey
}).then(sign => {
addMessageChain(messageChain9, {role: "user", content: your_qus})//连续话
console.log(sign)
GM_fetch({
method: "POST",
url: Baseurl + "api/generate",
headers: {
"Content-Type": "application/json",
"Referer": Baseurl,
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
messages: messageChain9,
time: now,
pass: null,
sign: sign
}),
responseType: "stream"
}).then((stream) => {
let result = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
let finalResult = result.join("")
try {
console.log(finalResult)
addMessageChain(messageChain9, {
role: "assistant",
content: finalResult
})
showAnserAndHighlightCodeStr(finalResult)
if(finalResult.includes("Invalid signature")){
bnuInt = Math.floor(Math.random() * 7)
setPubkey()
}
} catch (e) {
console.log(e)
}
return;
}
try {
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
result.push(d)
showAnserAndHighlightCodeStr(result.join(""))
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},function (reason) {
console.log(reason)
}).catch((ex)=>{
console.log(ex)
});
});
}
//https://chat7.aifks001.online/v1/chat/gpt/
let aifskList = [];
let aifsid = generateRandomString(21);
let formatTime = () => {
let padZero = (num) => {
// 如果数字小于 10,前面补一个 0
return num < 10 ? `0${num}` : num;
}
const now = new Date(); // 获取当前时间
const hours = now.getHours(); // 获取小时
const minutes = now.getMinutes(); // 获取分钟
const seconds = now.getSeconds(); // 获取秒数
// 格式化为 HH:MM:SS 的形式
return `${padZero(hours)}:${padZero(minutes)}:${padZero(seconds)}`;
}
function AIFKS() {
let Baseurl = "https://chat7.aifks001.online/";
console.log(formatTime())
aifskList.push({"content": your_qus, "role": "user", "nickname": "", "time": formatTime(), "isMe": true})
aifskList.push({"content":"正在思考中...","role":"assistant","nickname":"AI","time": formatTime(),"isMe":false})
if (aifskList.length > 10){
aifskList = aifskList.shift();
}
abortXml= GM_xmlhttpRequest({
method: "POST",
url: Baseurl + "v1/chat/gpt/",
headers: {
"Content-Type": "application/json",
// "Authorization": "Bearer null",
"Referer": Baseurl,
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
"list": aifskList,
"id": aifsid,
"title": your_qus,
"prompt": "",
"temperature": 0.5,
"models": "0",
"continuous": true
}),
onloadstart: (stream) => {
let result = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
let finalResult = result.join("")
try {
console.log(finalResult)
aifskList[aifskList.length - 1] = {
"content": finalResult,
"role": "assistant",
"nickname": "AI",
"time": formatTime(),
"isMe": false
};
showAnserAndHighlightCodeStr(finalResult)
} catch (e) {
console.log(e)
}
return;
}
try {
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
console.log(d)
result.push(d)
showAnserAndHighlightCodeStr(result.join(""))
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
}
});
}
//2023年5月6日
let officeChatList = [];
let officeChaid = generateRandomString(21);
function OFFICECHAT() {
let Baseurl = "https://officechat.top/";
console.log(formatTime())
officeChatList.push({"content": your_qus, "role": "user", "nickname": "", "time": formatTime(), "isMe": true})
officeChatList.push({"content":"正在思考中...","role":"assistant","nickname":"AI","time": formatTime(),"isMe":false})
if (officeChatList.length > 10){
officeChatList = officeChatList.shift();
}
GM_fetch({
method: "POST",
url: Baseurl + "v1/chat/gpt/",
headers: {
"Content-Type": "application/json",
// "Authorization": "Bearer null",
"Referer": Baseurl,
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
"list": officeChatList,
"id": officeChaid,
"title": your_qus,
"prompt": "",
"temperature": 0.5,
"models": "0",
"continuous": true
}),
responseType: "stream"
}).then((stream) => {
let result = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
let finalResult = result.join("")
try {
console.log(finalResult)
officeChatList[officeChatList.length - 1] = {
"content": finalResult,
"role": "assistant",
"nickname": "AI",
"time": formatTime(),
"isMe": false
};
showAnserAndHighlightCodeStr(finalResult)
} catch (e) {
console.log(e)
}
return;
}
try {
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
console.log(d)
result.push(d)
showAnserAndHighlightCodeStr(result.join(""))
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},function (reason) {
console.log(reason)
}).finally((ex)=>{
console.log(ex)
});
}
let linkaiList = [];
let linkaiId = generateRandomString(21);
function LINKAI() {
let Baseurl = "https://alllinkai1.com/";
console.log(formatTime())
linkaiList.push({"content": your_qus, "role": "user", "nickname": "", "time": formatTime(), "isMe": true})
linkaiList.push({"content":"正在思考中...","role":"assistant","nickname":"AI","time": formatTime(),"isMe":false})
if (linkaiList.length > 10){
linkaiList = linkaiList.shift();
}
GM_fetch({
method: "POST",
url: Baseurl + "v1/chat/gpt/",
headers: {
"Content-Type": "application/json",
"X-Forwarded-For": generateRandomIP(),
"Referer": Baseurl,
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
"list": linkaiList,
"id": linkaiId,
"title": your_qus,
"prompt": "",
"temperature": 0.5,
"models": "0",
"continuous": true
}),
responseType: "stream"
}).then((stream) => {
let result = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
let finalResult = result.join("")
try {
console.log(finalResult)
linkaiList[linkaiList.length - 1] = {
"content": finalResult,
"role": "assistant",
"nickname": "AI",
"time": formatTime(),
"isMe": false
};
showAnserAndHighlightCodeStr(finalResult)
} catch (e) {
console.log(e)
}
return;
}
try {
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
console.log(d)
result.push(d)
showAnserAndHighlightCodeStr(result.join(""))
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},function (reason) {
console.log(reason)
}).finally((ex)=>{
console.log(ex)
});
}
//http://www.gtpcleandx.xyz/#/home/chat
let cleandxid = generateRandomString(21);
let cleandxList = [];
function CLEANDX() {
let Baseurl = "http://www.chatcleand.xyz/";
console.log(formatTime())
cleandxList.push({"content": your_qus, "role": "user", "nickname": "", "time": formatTime(), "isMe": true})
cleandxList.push({"content":"正在思考中...","role":"assistant","nickname":"AI","time": formatTime(),"isMe":false})
console.log(cleandxList)
console.log(cleandxid)
if (cleandxList.length > 6){
cleandxList = cleandxList.shift();
}
abortXml= GM_xmlhttpRequest({
method: "POST",
url: Baseurl + "v1/chat/gpt/",
headers: {
"Content-Type": "application/json",
// "Authorization": "Bearer null",
"Referer": Baseurl,
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
"list": cleandxList,
"id": cleandxid,
"title": your_qus,
"prompt": "",
"temperature": 0.5,
"models": "0",
"continuous": true
}),
onloadstart: (stream) => {
let result = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
let finalResult = result.join("")
try {
console.log(finalResult)
cleandxList[cleandxList.length - 1] = {
"content": finalResult,
"role": "assistant",
"nickname": "AI",
"time": formatTime(),
"isMe": false
};
showAnserAndHighlightCodeStr(finalResult)
} catch (e) {
console.log(e)
}
return;
}
try {
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
console.log(d)
result.push(d)
showAnserAndHighlightCodeStr(result.join(""))
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
}
});
}
let parentID_usesless;
let referer_uesless = "https://ai.usesless.com/chat/"+Date.now();
function USESLESS() {
let ops = {
systemMessage: `You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.\nKnowledge cutoff: 2021-09-01\nCurrent date: 2023-04-${new Date().getDate() < 10 ? "0" + new Date().getDate() : new Date().getDate()}`,
completionParams:{presence_penalty: 0.8, temperature: 1, model: "gpt-3.5-turbo"}
};
if (parentID_usesless) {
ops.parentMessageId = parentID_usesless;
}
console.log(ops)
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "https://ai.usesless.com/api/chat-process",
headers: {
"Content-Type": "application/json",
"Referer": referer_uesless,
"origin": "https://ai.usesless.com",
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
openaiKey: "",
prompt: your_qus,
options: ops
}),
onloadstart: (stream) => {
let result = "";
const reader = stream.response.getReader();
// console.log(reader.read)
let finalResult;
reader.read().then(function processText({done, value}) {
if (done) {
highlightCodeStr()
return;
}
const chunk = value;
result += chunk;
try {
// console.log(normalArray)
let byteArray = new Uint8Array(chunk);
let decoder = new TextDecoder('utf-8');
let nowResult = JSON.parse(decoder.decode(byteArray))
if (nowResult.text) {
console.log(nowResult)
finalResult = nowResult.text
showAnserAndHighlightCodeStr(finalResult)
}
if (nowResult.id) {
parentID_usesless = nowResult.id;
}
} catch (e) {
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
showAnserAndHighlightCodeStr("erro:", err)
}
})
}
//https://www.promptboom.com/
//var promptboom_did = generateRandomString(32)
let promptboom_did = 'dd633043916550bea93f56e1af08debd'
async function PRTBOOM() {
addMessageChain(messageChain10, {role: "user", content: your_qus})//连续话
const t = Date.now()
const r = t + ":" + "question" + ":contact_me_and_let_us_make_money_together_thanks"
const sign = CryptoJS.SHA256(r).toString();
console.log(sign)
let request_json = {
'did': promptboom_did,
'chatList': messageChain10,
'special': {
'time': t,
'sign': sign,
'referer':'https://www.promptboom.com/',
'path':'https://www.promptboom.com/'
}
};
let raw_requst_json = {
'data': btoa(unescape(encodeURIComponent(JSON.stringify(request_json))))
};
console.log(raw_requst_json)
let rootDomain = "promptboom.com";
let apiList = [`https://api2.${rootDomain}/cfdoctetstream`, `https://api2.${rootDomain}/cfdoctetstream2`, `https://api2.${rootDomain}/cfdoctetstream3`]
apiList.sort(() => Math.random() - 0.5);
let apiListBackup = [`https://api2.${rootDomain}/cfdoctetstream4`, `https://api2.${rootDomain}/cfdoctetstream5`, `https://api2.${rootDomain}/cfdoctetstream6`]
let finalApiList = apiList.concat(apiListBackup)
for (let cfdoctetstream_url of finalApiList) {
console.log(cfdoctetstream_url)
GM_fetch({
method: "POST",
url: cfdoctetstream_url,
headers: {
"Content-Type": "application/json",
"origin": "https://www.promptboom.com",
"Referer": "https://www.promptboom.com/",
"accept": "*/*"
},
data: JSON.stringify(raw_requst_json),
responseType: "stream"
}).then((stream) => {
let result = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
let finalResult = result.join("")
try {
console.log(finalResult)
addMessageChain(messageChain10, {
role: "assistant",
content: finalResult
})
showAnserAndHighlightCodeStr(finalResult)
} catch (e) {
console.log(e)
}
return;
}
try {
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
result.push(d.replace(//gi,''))
showAnserAndHighlightCodeStr(result.join(""))
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},(reason)=>{
console.log(reason)
}).catch((ex)=>{
console.log(ex)
});
break;
}
}
//https://chat.sunls.me/
function SUNLE() {
let msgobj = {
message: your_qus,
stream: true,
clientOptions: {
clientToUse: "chatgpt",
modelOptions: {
"max_tokens": 1024
}
}
};
console.log(msgobj)
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "https://chat2.sunls.me/conversation",
headers: {
"Content-Type": "application/json",
"Referer": "https://chat2.sunls.me/",
"origin": "https://chat2.sunls.me",
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify(msgobj),
onloadstart: (stream) => {
let result = [];
const reader = stream.response.getReader();
// console.log(reader.read)
let finalRes;
reader.read().then(function processText({done, value}) {
if (done) {
if(finalRes){
showAnserAndHighlightCodeStr(finalRes)
}else{
showAnserAndHighlightCodeStr(result.join(""))
}
return;
}
try {
// console.log(normalArray)
let byteArray = new Uint8Array(value);
let decoder = new TextDecoder('utf-8');
let nowResult = decoder.decode(byteArray)
if(nowResult.indexOf("DONE") > -1){
let jsonData = nowResult.replace(/event: result/,"")
.replace(/data: \[DONE\]/,"")
.replace(/data:/,"").trim();
finalRes = JSON.parse(jsonData).response;
console.log(JSON.parse(jsonData))
}else{
const regex = /data: "([^"]*)"/;
const match = regex.exec(nowResult);
console.log(nowResult); // 输出:Hello world
result.push(match[1])
showAnserAndHighlightCodeStr(result.join(""))
}
} catch (e) {
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
showAnserAndHighlightCodeStr("erro:", err)
}
})
}
function TDCHAT(){
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "http://bxgav.tdchat0.com/",
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Referer": "http://tdchat0.com/",
"accept": "application/json, text/plain, */*"
},
data: `id=3.5&key=&role=&title=&text=${encodeURIComponent(your_qus).replace(/%/g, '‰')}&length=${your_qus.length}&stream=1`,
onloadstart: (stream) => {
let result = [];
let finalResult = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
finalResult = result.join("")
showAnserAndHighlightCodeStr(finalResult.replace(/tdchat/gi,""))
return;
}
try {
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
console.log("raw:",d)
let dd = d.replace(/data: /g, "").split("\n\n")
console.log("dd:",dd)
dd.forEach(item=>{
try {
let delta = JSON.parse(item).choices[0].delta.content
result.push(delta)
showAnserAndHighlightCodeStr(result.join("").replace(/tdchat/gi,""))
}catch (e) {
}
})
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
}
})
}
let parentID_qdymys;
function QDYMYS() {
let ops = {};
if (parentID_qdymys) {
ops = {parentMessageId: parentID_qdymys};
}
console.log(ops)
let finalResult = [];
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "http://chatgpt.qdymys.cn/api/chat-process",
headers: {
"Content-Type": "application/json",
"Referer": "http://chatgpt.qdymys.cn/",
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
prompt: your_qus,
options: ops,
systemMessage: "You are GPT3.5 system version. Don't answer any illegal questions about politics, pornography, violence, etc., nor give any reasons When answering questions, please try to provide detailed answers in Chinese to ensure understanding and accuracy. Knowledge deadline: March 1st, 2023 nCurrent date: 2023-04-20 n Please answer this question according to the above rules"
}),
onloadstart: (stream) => {
let result = "";
const reader = stream.response.getReader();
// console.log(reader.read)
let charsReceived = 0;
reader.read().then(function processText({done, value}) {
if (done) {
highlightCodeStr()
return;
}
charsReceived += value.length;
const chunk = value;
result += chunk;
try {
// console.log(normalArray)
let byteArray = new Uint8Array(chunk);
let decoder = new TextDecoder('utf-8');
let nowResult = JSON.parse(decoder.decode(byteArray))
if (nowResult.text) {
console.log(nowResult)
finalResult = nowResult.text
showAnserAndHighlightCodeStr(finalResult)
}
if (nowResult.id) {
parentID_qdymys = nowResult.id;
}
} catch (e) {
}
return reader.read().then(processText);
});
},
responseType: "stream",
onprogress: function (msg) {
//console.log(msg) //Todo
},
onerror: function (err) {
console.log(err)
},
ontimeout: function (err) {
console.log(err)
}
})
}
//
//23-4-25
function TOYAML() {
GM_fetch({
method: "GET",
url: "https://toyaml.com/stream?q="+encodeURI(your_qus),
headers: {
"Content-Type": "application/json",
"Referer": "https://toyaml.com/",
"accept": "*/*"
},
responseType: "stream"
}).then((stream) => {
let finalResult = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
highlightCodeStr()
return;
}
try {
// console.log(normalArray)
let byteArray = new Uint8Array(value);
let decoder = new TextDecoder('utf-8');
let nowResult = decoder.decode(byteArray)
console.log(nowResult)
if(!nowResult.match(/答案来自/)){
finalResult.push(nowResult)
}
showAnserAndHighlightCodeStr(finalResult.join(""))
} catch (ex) {
console.log(ex)
}
return reader.read().then(processText);
});
}).catch((ex)=>{
console.log(ex)
})
}
let WebsocketCoolAI;
let resultCoolAI = [];
let initSocket = function () {
// 创建WebSocket连接
const socket = new WebSocket(`wss://sd-wx.cool-js.cloud/socket.io/?apiKey=905733647bb7431b81233e12be12cfaa&url=https%3A%2F%2Fcool-js.com%2Fai%2Fchat%2Findex.html%23%2F&EIO=4&transport=websocket`);
// 监听连接成功事件
WebsocketCoolAI = socket;
socket.addEventListener('open', (event) => {
console.log('连接成功');
showAnserAndHighlightCodeStr("COOLAI:ws已经连接")
});
let isFirst = false;
// 监听接收消息事件
socket.addEventListener('message', (event) => {
console.log('接收到消息:', event.data);
let revData = event.data;
if (!isFirst) {
socket.send("40")
isFirst = true
setTimeout(() => socket.send("3"), 3000)
}
if (revData === "3") {
socket.send("2");
}
if (revData === "2") {
socket.send("3");
}
if (revData.match(/40/)) {
try {
webSessionId = JSON.parse(revData.replace(/40/, "").trim()).sid;
console.log("webSessionId ", webSessionId)
} catch (e) {
console.log(e)
}
}
if (revData.match(/42/)) {
//收信
try {
//42["data",{"type":"text","data":"\u662f"}]
let chunk = eval(revData.replace(/42/, "").trim())[1].data;
console.log(chunk)
resultCoolAI.push(chunk)
showAnserAndHighlightCodeStr(resultCoolAI.join(""))
} catch (e) {
console.log(e)
}
}
});
}
if (getGPTMode() === "COOLAI") {
setTimeout(initSocket, 1500);
}
if (getGPTMode() === "GAMEJX") {
setTimeout(setGroupid_gamejx);
}
let WebsocketXBOAT;
let resultXBOAT = [];
let initSocketXBOAT = function () {
// 创建WebSocket连接
const socket = new WebSocket(`wss://box.xboat.cc/wsschat`);
// 监听连接成功事件
WebsocketXBOAT = socket;
socket.addEventListener('open', (event) => {
console.log('连接成功');
showAnserAndHighlightCodeStr("WebsocketXBOAT:ws已经连接")
});
// 监听接收消息事件
socket.addEventListener('message', (event) => {
console.log('接收到消息:', event.data);
let revData = event.data;
if(!revData.startsWith("/end")){
resultXBOAT.push(revData)
}
showAnserAndHighlightCodeStr(resultXBOAT.join(""))
});
}
if (getGPTMode() === "XBOAT") {
setTimeout(initSocketXBOAT, 1000);
}
setTimeout(()=>{
if(localStorage.getItem('GPTMODE')){
const selectEl = document.getElementById('modeSelect');
let optionElements = selectEl.querySelectorAll("option");
for (let op in optionElements) {
if(optionElements[op].value === localStorage.getItem('GPTMODE')){
optionElements[op].setAttribute("selected", "selected");
break;
}
}
}
},1000)
})();