async function connectTunnel() { let targetUrl = document.getElementById('urlInput').value.trim(); const display = document.getElementById('displayNode'); const nodeType = document.getElementById('serverNode').value; if (!targetUrl) return; if (!targetUrl.startsWith('http://') && !targetUrl.startsWith('https://')) { targetUrl = 'https://' + targetUrl; } // レイアウトを検索後モードへシフト document.body.classList.add('searched'); display.style.display = 'block'; display.innerHTML = `

安全なプロキシ接続を確立しています...

`; let proxyUrl = ""; if (nodeType === "allorigins") { proxyUrl = `https://allorigins.win{encodeURIComponent(targetUrl)}`; } else if (nodeType === "corsproxy") { proxyUrl = `https://corsproxy.io{encodeURIComponent(targetUrl)}`; } try { const response = await fetch(proxyUrl); if (nodeType === "allorigins") { const jsonData = await response.json(); display.innerHTML = jsonData.contents; } else { const htmlText = await response.text(); display.innerHTML = htmlText; } } catch (error) { display.innerHTML = `

エラー: 接続を確立できませんでした。(${error.message})

`; } }