diff --git a/_worker.js b/_worker.js index ac2aec244..16499480b 100644 --- a/_worker.js +++ b/_worker.js @@ -5129,7 +5129,7 @@ async function Authenticate(request, env) { return false; } const { payload } = await jwtVerify(token, secret); - console.log(`Successfully logined, User ID: ${payload.userID}`); + console.log(`Successfully authenticated, User ID: ${payload.userID}`); return true; } catch (error) { console.log(error); @@ -5182,6 +5182,8 @@ function renderHomePage(request, proxySettings, hostName, isPassSet) { let activeProtocols = (vlessConfigs ? 1 : 0) + (trojanConfigs ? 1 : 0); let httpPortsBlock = "", httpsPortsBlock = ""; const allPorts = [...hostName.includes("workers.dev") ? defaultHttpPorts : [], ...defaultHttpsPorts]; + let regionNames = new Intl.DisplayNames(["en"], { type: "region" }); + const cfCountry = regionNames.of(request.cf.country); allPorts.forEach((port) => { let id = `port-${port}`; const isChecked = ports.includes(port) ? "checked" : ""; @@ -5529,9 +5531,9 @@ function renderHomePage(request, proxySettings, hostName, isPassSet) {
- - - @@ -5563,7 +5565,7 @@ function renderHomePage(request, proxySettings, hostName, isPassSet) {
- +
@@ -5636,8 +5638,8 @@ function renderHomePage(request, proxySettings, hostName, isPassSet) {
- -
@@ -5666,7 +5668,7 @@ function renderHomePage(request, proxySettings, hostName, isPassSet) { title="Please enter a valid Warp Plus license in xxxxxxxx-xxxxxxxx-xxxxxxxx format">
- + @@ -6162,24 +6164,27 @@ function renderHomePage(request, proxySettings, hostName, isPassSet) {

YOUR IP \u{1F4A1}

- +
+ - - - + + + + +
Address Your IP Country CityISP
Cloudflare${request.headers.get("cf-connecting-ip") || "Failed!"}${request.cf.city}${request.headers.get("cf-connecting-ip") || "Not found!"}${cfCountry || "Not found!"}${request.cf.city || "Not found!"}${request.cf.asOrganization || "Not found!"}
Others
@@ -6212,6 +6217,7 @@ function renderHomePage(request, proxySettings, hostName, isPassSet) { const closeBtn = document.querySelector(".close"); const passwordChangeForm = document.getElementById('passwordChangeForm'); const initialFormData = new FormData(configForm); + const modal = document.getElementById('myModal'); const closeQR = document.getElementById('closeQRModal'); const resetSettings = document.getElementById('resetSettings'); let modalQR = document.getElementById('myQRModal'); @@ -6252,7 +6258,6 @@ function renderHomePage(request, proxySettings, hostName, isPassSet) { configForm.addEventListener('input', enableApplyButton); configForm.addEventListener('change', enableApplyButton); changePass.addEventListener('click', () => { - const modal = document.getElementById('myModal'); forcedPassChange ? closeBtn.style.display = 'none' : closeBtn.style.display = ''; modal.style.display = "block"; document.body.style.overflow = "hidden"; @@ -6316,23 +6321,26 @@ function renderHomePage(request, proxySettings, hostName, isPassSet) { changePass.click(); } - let regionNames = new Intl.DisplayNames(['en'], {type: 'region'}); - const cfRegionName = regionNames.of('${request.cf.country}'); - document.getElementById('cfCountry').textContent = cfRegionName; - try { - const apiResponse = await fetch('https://ipinfo.io/json'); - const { ip, country, city } = await apiResponse.json(); + await fetchIPInfo(); + }); + + const fetchIPInfo = async () => { + const updateUI = (ip = 'Not found!', country = 'Not found!', city = 'Not found!', isp = 'Not found!') => { document.getElementById('ip').textContent = ip; - document.getElementById('country').textContent = regionNames.of(country); + document.getElementById('country').textContent = country; document.getElementById('city').textContent = city; + document.getElementById('isp').textContent = isp; + }; + + try { + const response = await fetch('https://ipwho.is/'); + const { ip, country, city, connection } = await response.json(); + updateUI(ip, country, city, connection.isp); } catch (error) { console.error('Error fetching IP address:', error); - document.getElementById('ip').textContent = 'Failed!'; - document.getElementById('country').textContent = 'Failed!'; - document.getElementById('city').textContent = 'Failed!'; - document.getElementById('ipError').textContent = '\u26A0\uFE0F IP info blocked by an Ad-blocker or extension. Please disable and refresh the page.'; + updateUI(); } - }); + } const getWarpConfigs = async () => { const license = document.getElementById('warpPlusLicense').value; @@ -6548,7 +6556,7 @@ function renderHomePage(request, proxySettings, hostName, isPassSet) { if (response.ok) { alert('\u2705 Parameters applied successfully \u{1F60E}'); - window.location.reload(true); + window.location.reload(); } else { const errorMessage = await response.text(); console.error(errorMessage, response.status); diff --git a/src/worker.js b/src/worker.js index 02baacc55..646b3391b 100644 --- a/src/worker.js +++ b/src/worker.js @@ -54,7 +54,7 @@ export default { status: 200, headers: { 'Content-Type': 'application/json;charset=utf-8', - }, + } }); case '/update-warp': @@ -1360,7 +1360,7 @@ async function Authenticate (request, env) { } const { payload } = await jwtVerify(token, secret); - console.log(`Successfully logined, User ID: ${payload.userID}`); + console.log(`Successfully authenticated, User ID: ${payload.userID}`); return true; } catch (error) { console.log(error); @@ -1415,6 +1415,8 @@ function renderHomePage (request, proxySettings, hostName, isPassSet) { let activeProtocols = (vlessConfigs ? 1 : 0) + (trojanConfigs ? 1 : 0); let httpPortsBlock = '', httpsPortsBlock = ''; const allPorts = [...(hostName.includes('workers.dev') ? defaultHttpPorts : []), ...defaultHttpsPorts]; + let regionNames = new Intl.DisplayNames(['en'], {type: 'region'}); + const cfCountry = regionNames.of(request.cf.country); allPorts.forEach(port => { let id = `port-${port}`; @@ -1764,9 +1766,9 @@ function renderHomePage (request, proxySettings, hostName, isPassSet) {
- - - @@ -1798,7 +1800,7 @@ function renderHomePage (request, proxySettings, hostName, isPassSet) {
- +
@@ -1871,8 +1873,8 @@ function renderHomePage (request, proxySettings, hostName, isPassSet) {
- -
@@ -1901,7 +1903,7 @@ function renderHomePage (request, proxySettings, hostName, isPassSet) { title="Please enter a valid Warp Plus license in xxxxxxxx-xxxxxxxx-xxxxxxxx format">
- + @@ -2397,24 +2399,27 @@ function renderHomePage (request, proxySettings, hostName, isPassSet) {

YOUR IP 💡

- +
+ - - - + + + + +
Address Your IP Country CityISP
Cloudflare${request.headers.get('cf-connecting-ip') || 'Failed!'}${request.cf.city}${request.headers.get('cf-connecting-ip') || 'Not found!'}${cfCountry || 'Not found!'}${request.cf.city || 'Not found!'}${request.cf.asOrganization || 'Not found!'}
Others
@@ -2447,6 +2452,7 @@ function renderHomePage (request, proxySettings, hostName, isPassSet) { const closeBtn = document.querySelector(".close"); const passwordChangeForm = document.getElementById('passwordChangeForm'); const initialFormData = new FormData(configForm); + const modal = document.getElementById('myModal'); const closeQR = document.getElementById('closeQRModal'); const resetSettings = document.getElementById('resetSettings'); let modalQR = document.getElementById('myQRModal'); @@ -2487,7 +2493,6 @@ function renderHomePage (request, proxySettings, hostName, isPassSet) { configForm.addEventListener('input', enableApplyButton); configForm.addEventListener('change', enableApplyButton); changePass.addEventListener('click', () => { - const modal = document.getElementById('myModal'); forcedPassChange ? closeBtn.style.display = 'none' : closeBtn.style.display = ''; modal.style.display = "block"; document.body.style.overflow = "hidden"; @@ -2551,23 +2556,26 @@ function renderHomePage (request, proxySettings, hostName, isPassSet) { changePass.click(); } - let regionNames = new Intl.DisplayNames(['en'], {type: 'region'}); - const cfRegionName = regionNames.of('${request.cf.country}'); - document.getElementById('cfCountry').textContent = cfRegionName; - try { - const apiResponse = await fetch('https://ipinfo.io/json'); - const { ip, country, city } = await apiResponse.json(); + await fetchIPInfo(); + }); + + const fetchIPInfo = async () => { + const updateUI = (ip = 'Not found!', country = 'Not found!', city = 'Not found!', isp = 'Not found!') => { document.getElementById('ip').textContent = ip; - document.getElementById('country').textContent = regionNames.of(country); + document.getElementById('country').textContent = country; document.getElementById('city').textContent = city; + document.getElementById('isp').textContent = isp; + }; + + try { + const response = await fetch('https://ipwho.is/'); + const { ip, country, city, connection } = await response.json(); + updateUI(ip, country, city, connection.isp); } catch (error) { console.error('Error fetching IP address:', error); - document.getElementById('ip').textContent = 'Failed!'; - document.getElementById('country').textContent = 'Failed!'; - document.getElementById('city').textContent = 'Failed!'; - document.getElementById('ipError').textContent = '⚠️ IP info blocked by an Ad-blocker or extension. Please disable and refresh the page.'; + updateUI(); } - }); + } const getWarpConfigs = async () => { const license = document.getElementById('warpPlusLicense').value; @@ -2783,7 +2791,7 @@ function renderHomePage (request, proxySettings, hostName, isPassSet) { if (response.ok) { alert('✅ Parameters applied successfully 😎'); - window.location.reload(true); + window.location.reload(); } else { const errorMessage = await response.text(); console.error(errorMessage, response.status);