redirect bingai to cloudflare challenge if needed

master
James Feng Cao 1 year ago
parent 63077ffe8f
commit 2c2f15bfa9

@ -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>

@ -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;

Loading…
Cancel
Save