mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
bingAI fix
This commit is contained in:
parent
8f2c1c9ad0
commit
ad4cc42d67
3 changed files with 49 additions and 28 deletions
|
@ -295,5 +295,14 @@ restartNewChat.onclick = async () => {
|
||||||
restart_button.onclick();
|
restart_button.onclick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function searchSuggestionsAddOnclick(){
|
||||||
|
let adds = document.querySelectorAll("#SearchSuggestions>a");
|
||||||
|
for(let add in adds){
|
||||||
|
adds[add].onclick = (event)=>{
|
||||||
|
if(searchSuggestions.style.opacity>=1){
|
||||||
|
send(event.target.innerHTML);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,29 +196,38 @@ function generateContentQueryImg(message, father){
|
||||||
theUrls.append('SFX', '2');
|
theUrls.append('SFX', '2');
|
||||||
theUrls.append('q', message.text);
|
theUrls.append('q', message.text);
|
||||||
theUrls.append('iframeid', message.requestId);
|
theUrls.append('iframeid', message.requestId);
|
||||||
let theUrl = URLTrue(magicUrl,"AiDraw/Create?") + theUrls.toString();
|
let theUrl = URLTrue(magicUrl,"images/create?") + theUrls.toString();
|
||||||
|
|
||||||
try{
|
try{
|
||||||
father.innerHTML = `正在生成${message.text}的图片.`;
|
father.innerHTML = `正在生成${message.text}的图片.`;
|
||||||
let html = (await (await fetch(theUrl)).text());
|
let html = (await (await fetch(theUrl)).text());
|
||||||
let urr = new RegExp('"/(images/create/async/results/(\\S*))"').exec(html);
|
|
||||||
if(!urr || !urr[1]){
|
//如果有错误就输出错误
|
||||||
urr = new RegExp('class="gil_err_mt">([^<>]*)</div>').exec(html);
|
let urr = new RegExp('class="gil_err_mt">([^<>]*)</div>').exec(html);
|
||||||
if(urr || urr[1]){
|
if(urr && urr[1]){
|
||||||
father.innerHTML = `${urr[1]}`
|
father.innerHTML = `<h3>${urr[1]}</h3>`
|
||||||
|
urr = new RegExp('class="gil_err_sbt">(([^<>]*<(a|div)[^<>]*>[^<>]*</(a|div)>[^<>]*)*)</div>').exec(html);
|
||||||
|
if(urr && urr[1]){
|
||||||
|
father.innerHTML = father.innerHTML+`<p>${urr[1]}</p>`;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//如果没错误就匹配链接获取图片
|
||||||
|
urr = new RegExp('"/(images/create/async/results/(\\S*))"').exec(html);
|
||||||
|
if(!urr || !urr[1]){
|
||||||
console.log(html);
|
console.log(html);
|
||||||
addError("请求图片返回不正确的页面,无法加载图片。");
|
addError("请求图片返回不正确的页面,无法加载图片。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let ur = urr[1];
|
let ur = urr[1];
|
||||||
|
ur = ur.replaceAll('&','&');
|
||||||
let imgPageHtmlUrl = URLTrue(magicUrl,ur);
|
let imgPageHtmlUrl = URLTrue(magicUrl,ur);
|
||||||
let count = 0;
|
let count = 0;
|
||||||
let run = async ()=>{
|
let run = async ()=>{
|
||||||
father.innerHTML = `正在生成${message.text}的图片.${count}`;
|
father.innerHTML = `正在生成${message.text}的图片.${count}`;
|
||||||
if(count>20){
|
if(count>20){
|
||||||
addError("请求图片超时!");
|
father.innerHTML = "请求图片超时!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
|
@ -232,22 +241,29 @@ function generateContentQueryImg(message, father){
|
||||||
setTimeout(run,3000);
|
setTimeout(run,3000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let div = document.createElement("div");
|
|
||||||
div.innerHTML = imgPageHtml;
|
father.innerHTML = '';
|
||||||
let imgs = div.getElementsByTagName("img");
|
|
||||||
let theUrls = new URLSearchParams();
|
let theUrls = new URLSearchParams();
|
||||||
theUrls.append('createmessage',message.text);
|
theUrls.append('createmessage',message.text);
|
||||||
father.innerHTML = '';
|
let a = document.createElement("a");
|
||||||
for(let el=0;el<imgs.length;el++){
|
father.appendChild(a);
|
||||||
let img = document.createElement('img');
|
//用正则找全部图片
|
||||||
img.src = imgs[el].src;
|
let allSrc = imgPageHtml.matchAll(/<img[^<>]*src="([^"]*)"[^<>]*>/g);
|
||||||
theUrls.append('imgs',img.src.split('?')[0]);
|
let src = undefined;
|
||||||
img.onclick = ()=>{
|
let ok = false;
|
||||||
window.open('chrome-extension://'+chrome.runtime.id+'/GeneratePicture/img.html?'+theUrls.toString(), '_blank');
|
while(!(src=allSrc.next()).done){
|
||||||
|
ok =true;
|
||||||
|
theUrls.append('imgs',src.value[1].split('?')[0]);
|
||||||
|
let img = document.createElement("img");
|
||||||
|
img.src = src.value[1];
|
||||||
|
a.appendChild(img);
|
||||||
}
|
}
|
||||||
father.appendChild(img);
|
if(ok){
|
||||||
|
a.target = '_blank';
|
||||||
|
a.href = '../GeneratePicture/img.html?'+theUrls.toString();
|
||||||
|
}else{
|
||||||
|
father.innerHTML = "服务器未正常返回图片!";
|
||||||
}
|
}
|
||||||
div.remove();
|
|
||||||
}
|
}
|
||||||
setTimeout(run,3000);
|
setTimeout(run,3000);
|
||||||
|
|
||||||
|
@ -396,11 +412,7 @@ function porserSuggestedResponses(suggestedResponses) {
|
||||||
for (let i = 0; i < suggestedResponses.length; i++) {
|
for (let i = 0; i < suggestedResponses.length; i++) {
|
||||||
let a = document.createElement('a');
|
let a = document.createElement('a');
|
||||||
a.innerHTML = suggestedResponses[i].text;
|
a.innerHTML = suggestedResponses[i].text;
|
||||||
a.onclick = (even) => {
|
|
||||||
if(searchSuggestions.style.opacity>=1){
|
|
||||||
send(even.target.innerHTML);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
searchSuggestions.appendChild(a);
|
searchSuggestions.appendChild(a);
|
||||||
}
|
}
|
||||||
|
searchSuggestionsAddOnclick();
|
||||||
}
|
}
|
|
@ -300,7 +300,7 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<p>Last Modified: 22 April 2023<br>
|
<p>Last Modified: 22 April 2023<br>
|
||||||
add newbing tips<br>
|
fix bingAI always 1/20 issue<br>
|
||||||
<pre></pre>
|
<pre></pre>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue