redirect bingai to cloudflare challenge if needed

This commit is contained in:
James Feng Cao 2023-06-19 20:55:00 +08:00
parent 63077ffe8f
commit 2c2f15bfa9
2 changed files with 10 additions and 1 deletions

View File

@ -312,7 +312,7 @@ Bundle of internal urls, if it is an "i:0" url, then it should have th
</div>
<p>Last Modified: 17 June 2023<br>
add i:8d[url] to force downloading<br>
finalize latest.html<br>
<pre>i:56 urls support CTRL_A to CTRL-Z
</pre>
</p>

View File

@ -235,6 +235,15 @@ async function createChat(theChatType) {
try {
let url = URLTrue(magicUrl,'turing/conversation/create');
let res = await fetch(url);
if(!res.ok){
if(res.headers.has('cf-mitigated')){
let challengeUrl = `${magicUrl}/challenge?`+location.href;
location.href=challengeUrl;
return;
}
mes = `Error code: ${res.status} ${res.statusText}`;
break;
}
let resjson = await res.json();
if (!resjson.result || resjson.result.value != 'Success') {
mes = resjson;