Spaces:
Running
Running
Upload index.html
Browse files406 unmodified lines4074084094104114124134144154164174184194204214224234244252 unmodified lines428429430431432433434406 unmodified lineschip.querySelector('.number').innerText = luckyNum;try {const response = await fetch(`https://www.angio.net/newpi/piquery?q=${luckyNum}`);if (!response.ok) throw new Error("API Server Error");const data = await response.json();if (data.status === 'OK' && data.r && data.r.length > 0) {finalVal = data.r[0].p;finalOutput = `在第 ${finalVal} 位`;} else {finalOutput = "在圓周率中未找到";}} catch (e) {console.error("API Error", e);finalOutput = "查詢失敗";}}2 unmodified lineschip.classList.remove('searching');resDiv.innerHTML = "";if(typeof finalVal === 'number'){chip.classList.add('done');resDiv.innerText = finalOutput;} else {406 unmodified lines4074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494502 unmodified lines453454455456457458459406 unmodified lineschip.querySelector('.number').innerText = luckyNum;try {// 目標 API 網址const targetUrl = `https://www.angio.net/newpi/piquery?q=${luckyNum}`;let data = null;// 實作多層 Proxy 備援機制,防止單一 Proxy 被阻礙或學校網路擋住try {// 優先使用 corsproxy (最快)const res = await fetch(`https://corsproxy.io/?${encodeURIComponent(targetUrl)}`);if (!res.ok) throw new Error("Proxy 1 Fail");data = await res.json();} catch (e1) {try {// 備用 1: codetabsconst res = await fetch(`https://api.codetabs.com/v1/proxy/?quest=${targetUrl}`);if (!res.ok) throw new Error("Proxy 2 Fail");data = await res.json();} catch (e2) {// 備用 2: alloriginsconst res = await fetch(`https://api.allorigins.win/raw?url=${encodeURIComponent(targetUrl)}`);if (!res.ok) throw new Error("Proxy 3 Fail");data = await res.json();}}if (data && data.status === 'OK' && data.r && data.r.length > 0) {const resultData = data.r[0];if (resultData.status === 'found') {finalVal = resultData.p;finalOutput = `在第 ${finalVal} 位`;} else {finalOutput = "在圓周率中未找到";}} else {throw new Error("Invalid API Response");}} catch (e) {console.error("API Error", e);finalOutput = "查詢失敗 (網路/CORS/無回應)";}}2 unmodified lineschip.classList.remove('searching');resDiv.innerHTML = "";if (typeof finalVal === 'number') {chip.classList.add('done');resDiv.innerText = finalOutput;} else {
index.html+35-10