版本: 1.9.1 已启动,部分线路需要科学上网,更换线路请点击"设置"。当前线路: ${localStorage.getItem("GPTMODE") || "Default"}
`
resolve(divE)
})
}
async function pivElemAddEventAndValue(append_case) {
var search_content
try {
if (append_case === 7) {
search_content = document.querySelector("#search_form input").value
}
if (append_case === 5) {
search_content = document.getElementById("search-input").value
}
if (append_case === 4) {
search_content = document.getElementById("keyword").value
}
if (append_case === 3) {
search_content = document.querySelectorAll("input")[0].value
}
if (append_case === 2) {
search_content = document.getElementById('kw').value
}
if (append_case === 1) {
try {
search_content = document.querySelector(
"#tsf > div:nth-child(1) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > input:nth-child(3)"
).value
} catch (e) {
search_content = document.querySelector("textarea").value
}
}
if (append_case === 0) {
search_content = document.getElementsByClassName('b_searchbox')[0].value
if (!search_content) {
search_content = document.querySelector("textarea[class='b_searchbox']").value;
}
}
} catch (e) {
console.log(e)
}
document.getElementById("gptInput").value = search_content
document.getElementById('button_GPT').addEventListener('click', () => {
your_qus = document.getElementById("gptInput").value
do_it()
})
document.getElementById('updatePubkey').addEventListener('click', () => {
document.getElementById("gptAnswer").innerText = "正在更新,请稍后..."
setPubkey()
})
document.getElementById('modeSelect').addEventListener('change', () => {
const selectEl = document.getElementById('modeSelect');
const selectedValue = selectEl.options[selectEl.selectedIndex].value;
localStorage.setItem('GPTMODE', selectedValue);
if (selectedValue === 'COOLAI') {
initSocket();
}
if (selectedValue === 'GAMEJX') {
setTimeout(setGroupid_gamejx)
}
document.getElementById('gptAnswer').innerHTML = `切换成功,当前线路:${selectedValue}`;
});
let chatSetting = false;
document.getElementById('chatSetting').addEventListener('click', () => {
if(!chatSetting){
//显示内容
try{
document.querySelector("#gptStatus").classList.remove("chatHide")
document.querySelector("#warn").classList.remove("chatHide")
document.querySelector("#website").classList.remove("chatHide")
}catch (e) {
console.log(e)
}
chatSetting = true;
}else{
//隐藏
try{
document.querySelector("#gptStatus").classList.add("chatHide")
document.querySelector("#warn").classList.add("chatHide")
document.querySelector("#website").classList.add("chatHide")
}catch (e) {
console.log(e)
}
chatSetting = false;
}
})
}
async function appendBox(append_case) {
return new Promise((resolve, reject) => {
creatBox().then((divE) => {
switch (append_case) {
case 0: //bing
if (divE) {
document.getElementById('b_context').prepend(divE)
}
break;
case 1: //google
if (document.getElementsByClassName('TQc1id ')[0]) {
document.getElementsByClassName('TQc1id ')[0].prepend(divE);
} else {
document.getElementById("rcnt").appendChild(divE);
}
break;
case 2: //baidu
if (document.getElementById('content_right')) {
document.getElementById('content_right').prepend(divE)
}
break;
case 3: //yandex
if (document.getElementById('search-result-aside')) {
document.getElementById('search-result-aside').prepend(divE)
}
break;
case 4: //360
if (document.getElementById('side')) {
document.getElementById('side').prepend(divE)
}
break;
case 5: //fsoufsou
let frow = document.querySelectorAll(".flex-row")[2]
if (frow.children!==undefined && frow.children.length === 2) {
frow.children.item(1).prepend(divE)
} else {
frow.innerHTML = frow.innerHTML +
`
`
}
break;
case 6: //手机百度
if (document.getElementById('page-bd')) {
document.getElementById('page-bd').prepend(divE)
//调整css
try {
document.querySelector("#gptDiv").style.setProperty("width",
"100%")
/*document.querySelector("#gptInput").setAttribute("class",
"se-input adjust-input")*/
} catch (e) {
//TODO handle the exception
}
setTimeout(() => {
document.getElementById("button_GPT").click(); //自动点击
}, 1500)
}
break;
case 7: //duckduckgo
if (document.querySelector('.results--sidebar div')) {
document.querySelector('.results--sidebar div').prepend(divE)
}
break;
default:
if (divE) {
console.log(`啥情况${divE}`)
}
}
}).catch((err) => {
throw new Error(err)
})
resolve("finished")
})
}
//焦点函数
function isBlur() {
var myInput = document.getElementById('gptInput');
if (myInput == document.activeElement) {
return 1
} else {
return 0
}
}
function keyEvent() {
document.onkeydown = function (e) {
var keyNum = window.event ? e.keyCode : e.which;
if (13 == keyNum) {
if (isBlur()) {
document.getElementById('button_GPT').click()
} else {
console.log("失焦不执行")
}
}
}
}
function addBothStyle() {
GM_addStyle(`
.gpt-container {
box-sizing: border-box;
height: -webkit-min-content;
height: min-content;
width: 455px;
margin-top: 8px;
margin-bottom: 8px;
border: 1px solid #dfe1e5;
border-radius: 8px;
overflow: hidden;
padding: 15px;
background-color:#fcfcfc
}
#dot{
height: 4px;
width: 4px;
display: inline-block;
border-radius: 2px;
animation: dotting 2.4s infinite step-start;
}
@keyframes dotting {
25%{
box-shadow: 4px 0 0 #71777D;
}
50%{
box-shadow: 4px 0 0 #71777D ,14px 0 0 #71777D;
}
75%{
box-shadow: 4px 0 0 #71777D ,14px 0 0 #71777D, 24px 0 0 #71777D;
}
}
pre{
overflow-x: scroll;
overflow-y: hidden;
background: #fffaec;
border-radius: 4px;
padding: 14px 3px;
}
pre::-webkit-scrollbar {
}
`)
}
function log(a) {
console.log(a)
}
function Uint8ArrayToString(fileData) {
var dataString = "";
for (var i = 0; i < fileData.length; i++) {
dataString += String.fromCharCode(fileData[i]);
}
return dataString
}
function decodeUnicode(str) {
str = str.replace(/\\/g, "%");
//转换中文
str = unescape(str);
//将其他受影响的转换回原来
str = str.replace(/%/g, "\\");
//对网址的链接进行处理
str = str.replace(/\\/g, "");
return str;
}
function mdConverter(rawData) {
var converter = new showdown.Converter(); //增加拓展table
converter.setOption('tables',
true); //启用表格选项。从showdown 1.2.0版开始,表支持已作为可选功能移入核心拓展,showdown.table.min.js扩展已被弃用
return converter.makeHtml(rawData);
}
//实时监控百度,360按钮消失
setInterval(() => {
//百度
if (window.location.href.indexOf("https:\/\/www.baidu.com\/s") > -1 && !isMobile()) {
if (!document.getElementById("gptDiv") && document.getElementById("mybtn")) {
document.getElementById("mybtn").click()
}
if (!document.getElementById("gptDiv") && !document.getElementById("mybtn")) {
addChatBtn();
document.getElementById("mybtn").click()
}
}
//360 注意请如果你在360相关浏览器上使用插件。360搜索将不会生效,因为已被浏览器禁用在so.com网址上使用
if (window.location.href.indexOf("so.com\/s") > -1 && !document.getElementById("gptDiv")) {
GM_add_box_style(1)
addBothStyle()
keyEvent()
appendBox(4).then((res) => {
pivElemAddEventAndValue(4)
})
}
}, 2000)
function generateRandomString(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for (var i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
var parentID_68686;
//http://chat.68686.ltd/
function LTD68686() {
let ops = {};
if (parentID_68686) {
ops = {parentMessageId: parentID_68686};
}
console.log(ops)
let finalResult = [];
GM_fetch({
method: "POST",
url: "http://38.47.97.76/api/chat-process",
headers: {
"Content-Type": "application/json",
"Referer": "http://38.47.97.76/",
"X-Forwarded-For": generateRandomIP(),
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
prompt: your_qus,
options: ops
}),
responseType: "stream"
}).then((stream) => {
const reader = stream.response.getReader();
// console.log(reader.read)
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 = JSON.parse(decoder.decode(byteArray))
if (nowResult.text) {
console.log(nowResult)
finalResult = nowResult.text
showAnserAndHighlightCodeStr(finalResult)
}
if (nowResult.id) {
parentID_68686 = nowResult.id;
}
} catch (e) {
}
return reader.read().then(processText);
});
},
(reason)=>{
console.log(reason)
}
).catch(ex => {
console.log(ex)
})
}
var messageChain2 = [];//AILS
var messageChain7 = [];//OHTOAI
var messageChain4 = [];//ESO
var messageChain5 = [];//XCBL
var messageChain6 = [];//HZIT
var messageChain8 = [];//lbb
var messageChain9 = [];//bnu120
var messageChain10 = [];//PRTBOOM
var messageChain1 = [
{
role: "system",
content: "请以markdown的形式返回答案"
}
];//default AIGCFUN
function addMessageChain(messageChain, element,maxLength) {
maxLength = maxLength || 6;
if (messageChain.length >= maxLength) {
messageChain.shift();
}
messageChain.push(element);
console.log(messageChain,maxLength)
return messageChain;
}
function formattedDate() {
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth() + 1;
const day = now.getDate();
const formattedMonth = month < 10 ? `0${month}` : month;
const formattedDay = day < 10 ? `0${day}` : day;
return `${year}-${formattedMonth}-${formattedDay}`;
}
function AILS() {
let vtime = function converTimestamp(t) {
const e = parseInt(t)
, n = e % 10
, r = n % 2 === 0 ? n + 1 : n;
return (e - n + r).toString()
}
let now = vtime(new Date().getTime());
const pk = `OVbi[TPN{S#)c{36%9?g;usl)CL:${your_qus.length}`;//查看js的generateSignature函数中的key
let Baseurl = "https://api.caipacity.com/"
generateSignatureWithPkey({
t: now,
m: your_qus || "",
pkey: pk
}).then(sign => {
addMessageChain(messageChain2, {role: "user", content: your_qus})//连续话
console.log(sign)
GM_fetch({
method: "POST",
url: Baseurl + "v1/chat/completions",
headers: {
"Content-Type": "application/json",
"authorization": "Bearer free",
"Referer": Baseurl,
"origin": "https://ai.ls",
"X-Forwarded-For": generateRandomIP(),
"accept": "application/json"
},
data: JSON.stringify({
model: "gpt-3.5-turbo",
messages: messageChain2,
stream: true,
t: `${now}`,
d: formattedDate(),
s: sign,
temperature:0.6
}),
responseType: "stream"
}).then((stream) => {
let result = [];
let finalResult;
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
finalResult = result.join("")
try {
console.log(finalResult)
addMessageChain(messageChain2, {
role: "assistant",
content: finalResult
})
showAnserAndHighlightCodeStr(finalResult)
} catch (e) {
console.log(e)
}
return;
}
try {
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
d.split("\n").forEach(item=>{
try {
let chunk = JSON.parse(item.replace(/data:/,"").trim())
.choices[0].delta.content;
result.push(chunk)
}catch (ex){}
})
showAnserAndHighlightCodeStr(result.join(""))
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},(reason)=>{
console.log(reason)
}).catch((ex)=>{
console.log(ex)
});
});
}
var messageChain11 = []//xeasy
function XEASY() {
let now = Date.now();
const pk = {}.PUBLIC_SECRET_KEY;//查看js的generateSignature函数中的key
let Baseurl = "https://chat19.xeasy.me/"
generateSignatureWithPkey({
t: now,
m: your_qus || "",
pkey: pk
}).then(sign => {
addMessageChain(messageChain11, {role: "user", content: your_qus})//连续话
console.log(sign)
GM_fetch({
method: "POST",
url: Baseurl + "api/generate",
headers: {
"Content-Type": "application/json",
// "Authorization": "Bearer null",
"Referer": Baseurl,
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
messages: messageChain11,
time: now,
pass: null,
sign: sign,
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(messageChain11, {
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);
});
},(reason)=>{
console.log(reason)
}).catch((ex)=>{
console.log(ex)
});
});
}
async function FDKANG() {
await GM_fetch({
method: "POST",
url: "http://chat.fdkang.top/setsession.php",
headers: {
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
"Referer": "http://chat.fdkang.top/"
},
data: `message=${encodeURI(your_qus)}&context=%5B%5D&key=`
})
GM_fetch({
method: "POST",
url: "http://chat.fdkang.top/stream.php",
headers: {
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
"Referer": "http://chat.fdkang.top/",
"accept": "text/event-stream"
},
responseType: "stream"
}).then((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);
});
},function (err) {
console.log(err)
}).catch((ex)=>{
console.log(ex)
})
}
function HZIT() {
let baseURL = "https://chargpt.hz-it-dev.com/";
addMessageChain(messageChain6, {role: "user", content: your_qus})//连续话
GM_xmlhttpRequest({
method: "POST",
url: baseURL + "send2",
headers: {
"Content-Type": "application/json",
"accept": "*/*",
"path": "v1/chat/completions",
"Referer": baseURL
},
data: JSON.stringify({
messages: messageChain6,
stream: true,
model: "gpt-3.5-turbo",
temperature: 1,
text: your_qus,
presence_penalty: 0
}),
onload:(res)=>{
if (res.status === 200) {
console.log('成功....')
console.log(res.response)
let rest = JSON.parse(res.response).data;
console.log(rest)
try {
showAnserAndHighlightCodeStr(rest);
addMessageChain(messageChain6, {
role: "assistant",
content: rest
})
} catch (e) {
//TODO handle the exception
document.getElementById('gptAnswer').innerHTML = `${rest}`
}
highlightCodeStr()
} else {
console.log(res)
document.getElementById('gptAnswer').innerHTML = '访问失败了'
}
},
onerror: function (err) {
console.log(err)
}
});
}
var messageChain3 = [];//DARRICKS
function DARRICKS() {
let baseURL = "https://chat.darricks.net/";
addMessageChain(messageChain3, {role: "user", content: your_qus})//连续话
GM_fetch({
method: "POST",
url: baseURL + "api/chat-stream",
headers: {
"Content-Type": "application/json",
"accept": "*/*",
"access-code": "j-2004",
"X-Forwarded-For": generateRandomIP(),
"path": "v1/chat/completions",
"Referer": baseURL
},
data: JSON.stringify({
messages: messageChain3,
stream: true,
model: "gpt-3.5-turbo",
temperature: 1,
presence_penalty: 0
})
}).then((res)=>{
if (res.status === 200) {
console.log(res.response)
let rest = res.response;
console.log(rest)
try {
showAnserAndHighlightCodeStr(rest);
addMessageChain(messageChain3, {
role: "assistant",
content: rest
})
} catch (ex) {
console.log(ex)
}
} else {
showAnserAndHighlightCodeStr(`访问失败了${res}`)
}
},function (err) {
console.log(err)
}).catch((ex)=>{
console.log(ex)
});
}
var userId_wgk = "#/chat/" + Date.now();
function WGK() {
console.log(userId_wgk)
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "https://chat2.wuguokai.cn/api/chat-process",
headers: {
"Content-Type": "application/json",
// "Authorization": "Bearer null",
"Referer": "https://chat.wuguokai.cn/",
//"Host":"www.aiai.zone",
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
prompt: your_qus,
userId: userId_wgk,
options: {}
}),
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');
let nowResult = decoder.decode(byteArray)
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)
}
})
}
var userId_yqcloud = "#/chat/" + Date.now();
function YQCLOUD() {
console.log(userId_yqcloud)
abortXml = GM_xmlhttpRequest({
method: "POST",
//url: "https://cbjtestapi.binjie.site:7777/api/generateStream",
url: "https://api.aichatos.cloud/api/generateStream",
headers: {
"Content-Type": "application/json",
"Referer": "https://chat6.aichatos.com/",
"origin": "https://chat6.aichatos.com",
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
prompt: your_qus,
apikey: "",
system: "",
withoutContext: false,
userId: userId_yqcloud,
network: true
}),
onloadstart: (stream) => {
let result = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
let finalResult = result.join("")
showAnserAndHighlightCodeStr(finalResult)
return;
}
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
result.push(d)
try {
console.log(result.join(""))
showAnserAndHighlightCodeStr(result.join(""))
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
showAnserAndHighlightCodeStr("error:", err)
}
})
}
var parentID_thebai;
function THEBAI() {
let ops = {};
if (parentID_thebai) {
ops = {parentMessageId: parentID_thebai};
}
console.log(ops)
let finalResult = [];
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "https://chatbot.theb.ai/api/chat-process",
headers: {
"Content-Type": "application/json",
"Referer": "https://chatbot.theb.ai/",
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
prompt: your_qus,
options: ops
}),
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_thebai = 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)
}
})
}
var parentID_xiami;
//https://chat.xiami.one/api/chat-process
function XIAMI() {
let ops = {};
if (parentID_xiami) {
ops = {parentMessageId: parentID_xiami};
}
console.log(ops)
let finalResult = [];
GM_httpRequest({
method: "POST",
url: "https://smart-chat.xiami.one/api/chat-process",
headers: {
"Content-Type": "application/json",
"Referer": "https://smart-chat.xiami.one/",
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
prompt: your_qus,
options: ops,
systemMessage:"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.",
top_p:1,
temperature:0.8
}),
responseType: "stream"
},(stream) => {
const reader = stream.response.getReader();
// console.log(reader.read)
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');
console.log(decoder.decode(byteArray))
let nowResult = JSON.parse(decoder.decode(byteArray))
if (nowResult.text) {
console.log(nowResult)
finalResult = nowResult.text
showAnserAndHighlightCodeStr(finalResult)
}
if (nowResult.id) {
parentID_xiami = nowResult.id;
}
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
})
}
var parentID_nbai;
function NBAI() {
let ops = {};
if (parentID_nbai) {
ops = {parentMessageId: parentID_nbai};
}
console.log(ops)
GM_fetch({
method: "POST",
url: "https://154.40.59.105:3006/api/chat-process",
headers: {
"Content-Type": "application/json",
"Referer": "https://f1.nbai.live/",
"accept": "application/json, text/plain, */*",
},
data: JSON.stringify({
prompt: your_qus,
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;
}
try {
let byteArray = new Uint8Array(value);
let decoder = new TextDecoder('utf-8');
let dstr = decoder.decode(byteArray)
if(dstr.includes("role")){
parentID_nbai = /\"parentMessageId\":\"(.*?)\"/gi.exec(dstr)[1]
}else{
console.log(dstr)
result.push(dstr)
finalResult = result.join("")
showAnserAndHighlightCodeStr(finalResult)
}
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
},(err)=> {
console.log(err)
}).catch((ex)=>{
console.log(ex)
})
})
}
var gamejx_group_id;
function setGroupid_gamejx() {
GM_fetch({
method: "POST",
url: "https://chat.gamejx.cn/go/api/group/add",
headers: {
"Referer": `https://chat.gamejx.cn/`,
"Content-Type": "application/json",
"Authorization": "C67E0aUHZ3QSAJ1B55qMKg3YVFV2ojPRPiWfwu0JFp4="
},
data:JSON.stringify({
version: "",
os: "pc",
language: "zh",
pars: {
user_id: "615933",
examples_id: "",
examples_describe: "你好"
}
})
}).then((res)=>{
if(res){
//{"code":200,"data":{"group_id":1292577},"retCode":"ok","retMsg":"success"}
console.log(res)
let data = eval(res.responseText)
gamejx_group_id = JSON.parse(AES_CBC.decrypt(data.slice(16), data.slice(0, 16))).data.group_id;
console.log("gamejx_group_id:",gamejx_group_id)
}
})
}
let is_first_gamejx = true;
async function GAMEJX(){
let req1 = await GM_fetch({
method: "POST",
url: "https://chat.gamejx.cn/go/api/steam/see",
headers: {
"Referer": `https://chat.gamejx.cn/`,
"Content-Type": "application/json",
"Authorization": "C67E0aUHZ3QSAJ1B55qMKg3YVFV2ojPRPiWfwu0JFp4="
},
data:JSON.stringify({
"version": "",
"os": "pc",
"language": "zh",
"pars": {
"user_id": "615933",
"question": is_first_gamejx ? "你好" : your_qus,
"group_id": `${gamejx_group_id}`,
"question_id": ""
}
})
})
console.log(req1.responseText)
//{"code":200,"data":{"answer":"","question_id":"91303","type":"answer",
// "user_id":"594578"},"retCode":"ok","retMsg":"success"}
if(req1.responseText){
try {
let data = eval(req1.responseText)
console.log(JSON.parse(AES_CBC.decrypt(data.slice(16), data.slice(0, 16))))
let question_id = JSON.parse(AES_CBC.decrypt(data.slice(16), data.slice(0, 16))).data.question_id;
console.log("question_id:",question_id)
GM_fetch({
method: "GET",
url: `https://chat.gamejx.cn/go/api/event/see?question_id=${question_id}&group_id=${gamejx_group_id}&user_id=615933&token=C67E0aUHZ3QSAJ1B55qMKg3YVFV2ojPRPiWfwu0JFp4%3D`,
headers: {
"Content-Type": "application/json",
"Referer": "https://chat.gamejx.cn/",
"accept": "text/event-stream"
},
responseType: "stream"
}).then((stream) => {
let finalResult = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
showAnserAndHighlightCodeStr(finalResult.join(""))
return;
}
try {
let byteArray = new Uint8Array(value);
let decoder = new TextDecoder('utf-8');
let nowResult = decoder.decode(byteArray)
console.log(nowResult)
nowResult.split("\n").forEach(item=>{
try {
let chunk = JSON.parse(item.replace(/data:/,"").trim()).Data;
finalResult.push(chunk)
}catch (ex){}
})
showAnserAndHighlightCodeStr(finalResult.join(""))
} catch (ex) {
console.log(ex)
}
return reader.read().then(processText);
});
}).catch((ex)=>{
console.log(ex)
})
}catch (ex){
console.log(ex)
}
}
if(is_first_gamejx === true){
is_first_gamejx = false;
await GAMEJX()
}
}
var 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.response)
let rest = res.response
//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: "application/json;charset=UTF-8",
onerror: function (err) {
document.getElementById('gptAnswer').innerHTML =
`
some err happends,errinfo :
${err.messages}
`
}
});
}
function PHIND() {
GM_xmlhttpRequest({
method: "POST",
url: "https://www.phind.com/api/bing/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.response)
let rest = res.response
//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)
document.getElementById('gptAnswer').innerHTML = '访问失败了'
}
},
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
})
}
var 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))
var 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)
}
})
}
var 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)
}
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)
}
})
}
var parentID_hhw;
function HEHANWANG() {
let ops = {};
if (parentID_hhw) {
ops = {parentMessageId: parentID_hhw};
}
console.log(ops)
GM_fetch({
method: "POST",
url: "https://chat.hehanwang.com/api/chat-process",
headers: {
"Content-Type": "application/json",
"Referer": "https://chat.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))
var 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)
});
}
function OHTOAI() {
// let baseURL = "https://chat.ohtoai.com/";
let baseURL = "https://chat.bushiai.com/";
addMessageChain(messageChain7, {role: "user", content: your_qus})//连续话
GM_xmlhttpRequest({
method: "POST",
url: baseURL + "api/chat-stream",
headers: {
"Content-Type": "application/json",
"access-code": "",
"path": "v1/chat/completions",
"Referer": baseURL
},
data: JSON.stringify({
messages: messageChain7,
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(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);
});
},
responseType: "stream",
onprogress: function (msg) {
//console.log(msg)
},
onerror: function (err) {
console.log(err)
},
ontimeout: function (err) {
console.log(err)
}
});
}
//https://gpt.esojourn.org/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": "pub04-23Xs67AErn454",
"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://132122401530.ai001.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
},
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)
}
});
}
var 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__").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/",
"accept": "application/json, text/plain, */*"
},
data: JSON.stringify({
prompt: pt,
options: 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()}`
}),
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://gpt.ai001.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.response)
let rest = res.response
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
var sessionId_easyai = generateRandomString(20);
var easyai_ip = generateRandomIP();
function EASYAI() {
console.log(sessionId_easyai)
abortXml = GM_xmlhttpRequest({
method: "POST",
url: `http://easyai.one/easyapi/v1/chat/completions?message=${encodeURI(your_qus)}&sessionId=${sessionId_easyai}`,
headers: {
"Referer": "http://easyai.one/chat",
"X-Forwarded-For": easyai_ip,
"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)
}
})
}
//https://chat.bnu120.space/
function BNU120() {
let now = Date.now();
let Baseurl = "https://chat.0.bnu120.space/"
generateSignatureWithPkey({
t: now,
m: your_qus || "",
pkey: "contact_me_at_admin@muspimerol.site!"
}).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)
} 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/
var aifskList = [];
var aifsid = generateRandomString(21);
var 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)
}
});
}
//http://www.gtpcleandx.xyz/#/home/chat
var cleandxid = generateRandomString(21);
var 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)
}
});
}
var parentID_usesless;
var 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)
async function PRTBOOM() {
addMessageChain(messageChain10, {role: "user", content: your_qus})//连续话
const t = Date.now()
const r = t + ":" + your_qus + ":please_do_not_hack_me_you_are_so_talented_you_can_contact_me_and_let_us_make_money_together"
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)
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://chat1.sunls.me/conversation",
headers: {
"Content-Type": "application/json",
"Referer": "https://chat1.sunls.me/",
"origin": "https://chat1.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)
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)
}
})
}
var 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)
})
}
var WebsocketCoolAI;
var resultCoolAI = [];
var 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 (localStorage.getItem("GPTMODE") === "COOLAI") {
setTimeout(initSocket, 1500);
}
if (localStorage.getItem("GPTMODE") === "GAMEJX") {
setTimeout(setGroupid_gamejx);
}
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)
})();