版本: 1.5.9已启动,部分需要魔法。当前线路: ${localStorage.getItem("GPTMODE") ? 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();
}
document.getElementById('gptAnswer').innerHTML = `切换成功,当前模式:${selectedValue}模式`;
});
}
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.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(`
#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;
function LTD68686() {
let ops = {};
if (parentID_68686) {
ops = {parentMessageId: parentID_68686};
}
console.log(ops)
let finalResult = [];
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "https://chat.68686.ltd/api/chat-process",
headers: {
"Content-Type": "application/json",
"Referer": "https://chat.68686.ltd/",
"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_68686 = nowResult.id;
}
} catch (e) {
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
}
})
}
var messageChain2 = [];//AILS
var messageChain4 = [];//LTXUK
var messageChain5 = [];//XEASY
var messageChain6 = [];//MYDOG
var messageChain7 = [];//OHTOAI
var messageChain8 = [];//SUPREMES
var messageChain9 = [];//bnu120
var messageChain10 = [];//ftcl
var messageChain3 = [];//LETSEARCH
var messageChain1 = [
{
role: "system",
content: "请以markdown的形式返回答案"
}
];//default AIGCFUN
function addMessageChain(messageChain, element) {
if (messageChain.length >= 6) {
messageChain.shift();
}
messageChain.push(element);
console.log(messageChain)
}
function AILS() {
let now = Date.now();
const pk = `Na3dx_(?qx32l}ep?#:8:mo44;7W\\2W.:nxm:${your_qus.length}`;//查看js的generateSignature函数中的key
let Baseurl = "https://ai.ls/"
generateSignatureWithPkey({
t: now,
m: your_qus || "",
pkey: pk
}).then(sign => {
addMessageChain(messageChain2, {role: "user", content: your_qus})//连续话
console.log(sign)
GM_xmlhttpRequest({
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: messageChain2,
time: now,
pass: null,
sign: sign,
key: ""
}),
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(messageChain2, {
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)
}
});
});
}
function LERSEARCH() {
let baseURL = "https://chatgpt.letsearches.com/";
addMessageChain(messageChain3, {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: messageChain3,
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(messageChain3, {
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)
}
});
}
var userId_wgk = "#/chat/" + Date.now();
function WGK() {
console.log(userId_wgk)
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "https://ai5.wuguokai.top/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",
headers: {
"Content-Type": "application/json",
"Referer": "http://choiajsd.aichatos.com/",
"origin": "choiajsd.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_aidutu;
function AIDUTU() {
let _iam = generateRandomString(8)
let ops = {};
if (parentID_aidutu) {
ops = {parentMessageId: parentID_aidutu};
}
console.log(ops)
GM_xmlhttpRequest({
url: "https://chat.aidutu.cn/api/cg/chatgpt/user/info?v=1.5",
headers: {
"accept": "*/*",
"referrer": "https://chat.aidutu.cn/",
"x-iam:": _iam,
"content-type": "application/json"
},
data: JSON.stringify({
q: your_qus,
iam: _iam
}),
method: "POST",
onload: (resp) => {
let rs = resp.responseText;
console.log(rs)
let xtoken = JSON.parse(rs).data.token;
console.log(xtoken)
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "https://chat.aidutu.cn/api/chat-process",
headers: {
"Content-Type": "application/json",
"Referer": "https://chat.aidutu.cn/",
"accept": "application/json, text/plain, */*",
"x-token": xtoken
},
data: JSON.stringify({
prompt: your_qus,
temperature: 0.8,
top_p: 1,
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();
// 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');
let nowResult = JSON.parse(decoder.decode(byteArray))
console.log(nowResult)
if (nowResult.text) {
console.log(nowResult)
finalResult = nowResult.text
showAnserAndHighlightCodeStr(finalResult)
}
if (nowResult.id) {
parentID_aidutu = nowResult.id;
}
} catch (e) {
console.log(e)
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
}
})
}//end onload
})
}
function LTXUK() {
let now = Date.now()
const pk = {}.PUBLIC_SECRET_KEY;
generateSignatureWithPkey({
t: now,
m: your_qus || "",
pkey: pk
}).then(sign => {
console.log(sign)
addMessageChain(messageChain4, {role: "user", content: your_qus})//连续话
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "https://luntianxia.uk/api/generate",
headers: {
"Content-Type": "application/json",
"Referer": `https://luntianxia.uk/`
},
data: JSON.stringify({
messages: messageChain4,
time: now,
pass: null,
sign: sign
//key: "",
//usage: Math.floor(Math.random() * 8) + 1
}),
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 {
log(rest)
showAnserAndHighlightCodeStr(rest)
addMessageChain(messageChain4, {
role: "assistant",
content: rest
})
} catch (e) {
//TODO handle the exception
console.log(e)
document.getElementById('gptAnswer').innerHTML = `${rest}`
}
highlightCodeStr()
} else {
console.log('失败')
console.log(res)
document.getElementById('gptAnswer').innerHTML = '访问失败了'
}
},
responseType: "application/json;charset=UTF-8",
onprogress: function (msg) {
//console.log(msg) //Todo
},
onerror: function (err) {
document.getElementById('gptAnswer').innerHTML =
`
some err happends,errinfo :
${err.messages}
`
},
ontimeout: function (err) {
document.getElementById('gptAnswer').innerHTML =
`
Opps!TimeOut,Please try again,errinfo:
${err.messages}
`
}
});
});
}
function XEASY() {
let now = Date.now()
const pk = {}.PUBLIC_SECRET_KEY;
generateSignatureWithPkey({
t: now,
m: your_qus || "",
pkey: pk
}).then(sign => {
console.log(sign)
addMessageChain(messageChain5, {role: "user", content: your_qus})//连续话
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "https://chat6.xeasy.me/api/generate",
headers: {
"Content-Type": "application/json",
"Referer": `https://chat6.xeasy.me/`
},
data: JSON.stringify({
messages: messageChain5,
time: now,
pass: null,
sign: sign
//key: "",
//usage: Math.floor(Math.random() * 8) + 1
}),
onloadstart: (stream) => {
let result = [];
const reader = stream.response.getReader();
reader.read().then(function processText({done, value}) {
if (done) {
let finalResult = result.join("")
console.log(finalResult)
showAnserAndHighlightCodeStr(finalResult)
addMessageChain(messageChain5, {
role: "assistant",
content: finalResult
})
return;
}
let d = new TextDecoder("utf8").decode(new Uint8Array(value));
result.push(d)
try {
showAnserAndHighlightCodeStr(result.join(""))
} catch (e) {
log(e)
}
return reader.read().then(processText);
});
},
responseType: "stream",
onprogress: function (msg) {
//console.log(msg) //Todo
},
onerror: function (err) {
document.getElementById('gptAnswer').innerHTML =
`
some err happends,errinfo :
${err.messages}
`
},
ontimeout: function (err) {
document.getElementById('gptAnswer').innerHTML =
`
Opps!TimeOut,Please try again,errinfo:
${err.messages}
`
}
});
});
}
function MYDOG() {
let now = Date.now();
const pk = {}.pkey;//查看js的generateSignature函数中的key
let Baseurl = "https://a.mydog.buzz/"
generateSignatureWithPkey({
t: now,
m: your_qus || "",
pkey: pk
}).then(sign => {
addMessageChain(messageChain6, {role: "user", content: your_qus})//连续话
console.log(sign)
GM_xmlhttpRequest({
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: messageChain6,
time: now,
continuous: true,
code: "",
sign: sign,
customKey: ""
}),
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(messageChain6, {
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)
}
});
});
}
var parentID_wobcw;
function WOBCW() {
let ops = {};
if (parentID_wobcw) {
ops = {parentMessageId: parentID_wobcw};
}
console.log(ops)
abortXml = GM_xmlhttpRequest({
method: "POST",
url: "https://gpt.wobcw.com/api/chat-process",
headers: {
"Content-Type": "application/json",
"Referer": "https://gpt.wobcw.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');
let nowResult = JSON.parse(decoder.decode(byteArray))
if (nowResult.text) {
console.log(nowResult)
finalResult = nowResult.text
showAnserAndHighlightCodeStr(finalResult)
}
if (nowResult.id) {
parentID_wobcw = nowResult.id;
}
} catch (e) {
}
return reader.read().then(processText);
});
},
responseType: "stream",
onerror: function (err) {
console.log(err)
showAnserAndHighlightCodeStr("erro:", err)
}
})
}
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 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)
}
})
}
function OHTOAI() {
let baseURL = "https://chat.ohtoai.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)
}
});
}
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://mirrorchat.extkj.cn/api/chat-stream",
headers: {
"Content-Type": "application/json",
"Referer": "https://mirrorchat.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)
}
})
}
//https://supremes.pro/
function SUPREMES() {
let now = Date.now();
let Baseurl = "https://supremes.pro/"
generateSignatureWithPkey({
t: now,
m: your_qus || "",
pkey: {}.PUBLIC_SECRET_KEY
}).then(sign => {
addMessageChain(messageChain8, {role: "user", content: your_qus})//连续话
console.log(sign)
GM_xmlhttpRequest({
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: messageChain8,
time: now,
pass: null,
sign: sign,
key: ""
}),
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(messageChain8, {
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://chat.bnu120.space/
function BNU120() {
let now = Date.now();
let Baseurl = "https://chat.bnu120.space/"
generateSignatureWithPkey({
t: now,
m: your_qus || "",
pkey: {}.PUBLIC_SECRET_KEY
}).then(sign => {
addMessageChain(messageChain9, {role: "user", content: your_qus})//连续话
console.log(sign)
GM_xmlhttpRequest({
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: messageChain9,
time: now,
pass: null,
sign: sign,
key: ""
}),
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(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);
});
},
responseType: "stream",
onprogress: function (msg) {
//console.log(msg)
},
onerror: function (err) {
console.log(err)
},
ontimeout: function (err) {
console.log(err)
}
});
});
}
//https://chat7.aifks001.online/v1/chat/gpt/
var aifskList = [];
var aifsid = generateRandomString(21);
function AIFKS() {
let Baseurl = "https://chat7.aifks001.online/";
let padZero = (num) => {
// 如果数字小于 10,前面补一个 0
return num < 10 ? `0${num}` : num;
}
let formatTime = () => {
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)}`;
}
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)
}
});
}
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)
}
})
}
function FTCL() {
let now = Date.now();
let Baseurl = "https://www.ftcl.store/"
generateSignatureWithPkey({
t: now,
m: your_qus || "",
pkey: {}.PUBLIC_SECRET_KEY
}).then(sign => {
addMessageChain(messageChain10, {role: "user", content: your_qus})//连续话
console.log(sign)
GM_xmlhttpRequest({
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: messageChain10,
time: now,
pass: null,
sign: sign,
key: ""
}),
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(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);
});
},
responseType: "stream",
onprogress: function (msg) {
//console.log(msg)
},
onerror: function (err) {
console.log(err)
},
ontimeout: function (err) {
console.log(err)
}
});
});
}
//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://chat.sunls.me/conversation",
headers: {
"Content-Type": "application/json",
"Referer": "https://chat.sunls.me/",
"origin": "https://chat.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: "https://api.tdchat0.com/",
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
// "Authorization": "Bearer null",
"Referer": "http://hzcy5.tdchat6.com/",
//"Host":"www.aiai.zone",
"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 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);
}
})();