127 lines
7.4 KiB
JavaScript
127 lines
7.4 KiB
JavaScript
/* ==== IPV6PAGE: IPv4/IPv6 线路选择页(注入片段,纯函数,无模块依赖) ==== */
|
|
function IPV6PAGE(e){
|
|
const proto=(e&&e.headers&&e.headers.get("x-forwarded-proto"))||"https";
|
|
const host=(e&&e.headers&&e.headers.get("host"))||"tv.88531.cn";
|
|
const back="/";
|
|
const html=`<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
|
<title>选择线路 · 米视TV</title><style>
|
|
*{box-sizing:border-box;margin:0;padding:0}
|
|
body{min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;
|
|
font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;
|
|
background:#0f0f1a;color:#fff;padding:24px;
|
|
background-image:radial-gradient(circle at 20% 20%,rgba(168,85,247,.18),transparent 45%),
|
|
radial-gradient(circle at 80% 80%,rgba(59,130,246,.16),transparent 45%)}
|
|
.logo{font-size:22px;font-weight:700;margin-bottom:6px;
|
|
background:linear-gradient(90deg,#a855f7,#3b82f6);-webkit-background-clip:text;background-clip:text;color:transparent}
|
|
.sub{font-size:13px;color:rgba(255,255,255,.55);margin-bottom:6px}
|
|
.status{font-size:12px;color:rgba(255,255,255,.45);margin-bottom:26px;min-height:16px}
|
|
.notice{display:none;width:100%;max-width:560px;margin-bottom:20px;padding:13px 16px;border-radius:12px;
|
|
background:rgba(239,68,68,.12);border:1px solid rgba(239,68,68,.38);color:#fca5a5;
|
|
font-size:13px;line-height:1.7;text-align:center}
|
|
.cards{display:flex;gap:16px;width:100%;max-width:560px;flex-wrap:wrap;justify-content:center}
|
|
.card{flex:1 1 220px;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.12);
|
|
border-radius:16px;padding:26px 22px;cursor:pointer;transition:all .2s;text-align:left;
|
|
backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}
|
|
.card:hover{transform:translateY(-4px);border-color:rgba(168,85,247,.6);
|
|
box-shadow:0 12px 32px rgba(168,85,247,.22)}
|
|
.card:active{transform:translateY(-1px)}
|
|
.card .icon{font-size:30px;margin-bottom:12px}
|
|
.card .name{font-size:18px;font-weight:700;margin-bottom:6px}
|
|
.card .desc{font-size:12px;color:rgba(255,255,255,.55);line-height:1.7}
|
|
.card.v4{--c:#3b82f6}
|
|
.card.v6{--c:#10b981}
|
|
.card:hover{border-color:var(--c)}
|
|
.badge{display:inline-block;margin-top:12px;font-size:11px;padding:3px 10px;border-radius:999px;
|
|
background:color-mix(in srgb,var(--c) 22%,transparent);color:var(--c);border:1px solid color-mix(in srgb,var(--c) 40%,transparent)}
|
|
.tip{margin-top:28px;font-size:12px;color:rgba(255,255,255,.4);text-align:center;max-width:420px;line-height:1.8}
|
|
.go{margin-top:20px;padding:10px 24px;border:none;border-radius:10px;font-size:14px;font-weight:600;
|
|
background:linear-gradient(90deg,#a855f7,#3b82f6);color:#fff;cursor:pointer}
|
|
.go:hover{opacity:.9}
|
|
.rebtn{margin-top:10px;padding:7px 18px;border:1px solid rgba(239,68,68,.5);border-radius:8px;
|
|
background:rgba(239,68,68,.15);color:#fca5a5;font-size:13px;cursor:pointer;transition:all .2s}
|
|
.rebtn:hover{background:rgba(239,68,68,.3);color:#fff}
|
|
</style></head><body>
|
|
<div class="logo">米视TV</div>
|
|
<div class="sub">选择你当前网络可用的访问线路</div>
|
|
<div class="status" id="st">正在检测 IPv6 可用性…</div>
|
|
<div class="notice" id="nt">⚠️ 检测到你的网络<b>不支持 IPv6 访问</b>,已隐藏 IPv6 线路。<br>请使用 IPv4 线路访问。<br><button class="rebtn" onclick="__reprobe()">重新检测</button> <button class="rebtn" onclick="__forceV6()">仍要使用 IPv6</button></div>
|
|
<div class="cards">
|
|
<div class="card v4" onclick="__go('v4')">
|
|
<div class="icon">🌐</div>
|
|
<div class="name">IPv4 线路</div>
|
|
<div class="desc">标准线路,绝大多数运营商可用<br>推荐电信/联通/移动家用宽带</div>
|
|
<div class="badge">推荐 · 最稳</div>
|
|
</div>
|
|
<div class="card v6" id="c6" onclick="__go('v6')">
|
|
<div class="icon">⚡</div>
|
|
<div class="name">IPv6 线路</div>
|
|
<div class="desc">更高速线路,需网络支持 IPv6<br>访问更快,晚高峰更流畅</div>
|
|
<div class="badge">高速 · 需 IPv6</div>
|
|
</div>
|
|
</div>
|
|
<button class="go" onclick="__go(localStorage.getItem('__v6dest')||'v4')">进入米视TV</button>
|
|
<div class="tip">选择后会记住你的偏好,下次自动使用。<br>随时可在页面右上角「IPV4/IPV6」按钮切换线路。</div>
|
|
<script>
|
|
var H={v4:"https://tv.88531.cn",v6:"https://tv6.88531.cn:4443"};
|
|
var __v6ok=true;
|
|
function __go(k){
|
|
if(k==='v6'&&!__v6ok)k='v4';
|
|
try{localStorage.setItem("__v6dest",k)}catch(e){}
|
|
location.href=(H[k]||H.v4)+"${back}"+location.search+location.hash}
|
|
function __hideV6(msg){
|
|
__v6ok=false;
|
|
var c=document.getElementById('c6');if(c)c.style.display='none';
|
|
var n=document.getElementById('nt');if(n)n.style.display='block';
|
|
var s=document.getElementById('st');if(s)s.style.display='none';
|
|
try{if(localStorage.getItem("__v6dest")==='v6')localStorage.setItem("__v6dest","v4")}catch(e){}
|
|
}
|
|
function __showV6(){
|
|
__v6ok=true;
|
|
var s=document.getElementById('st');if(s){s.textContent='✓ 已检测到你的网络支持 IPv6';s.style.color='#34d399'}
|
|
}
|
|
function __probe(){
|
|
// 当前就在 IPv6 域名上,必然可用
|
|
if(location.hostname==='tv6.88531.cn'){__showV6();return}
|
|
// 结果缓存 2 分钟,避免每次刷新都等检测(但不失效太快)
|
|
try{var j=JSON.parse(localStorage.getItem("__v6probe")||"null");
|
|
if(j&&(Date.now()-j.t)<120000){j.ok?__showV6():__hideV6();return}}catch(e){}
|
|
// tv6.88531.cn 只有 AAAA 记录:用 cors 模式拿真实状态并校验响应体。
|
|
// 双端口依次探测(家宽可能封 443,非标端口 4443 放行),任一成功即判定支持 IPv6。
|
|
var __urls=["https://tv6.88531.cn:4443/api/license-config?_=",
|
|
"https://tv6.88531.cn/api/license-config?_="];
|
|
function __try(i){
|
|
if(i>=__urls.length){
|
|
try{localStorage.setItem("__v6probe",JSON.stringify({t:Date.now(),ok:false}))}catch(e){}
|
|
__hideV6();return}
|
|
var c=new AbortController();
|
|
var ti=setTimeout(function(){c.abort()},5000);
|
|
fetch(__urls[i]+Date.now(),{mode:"cors",signal:c.signal,cache:"no-store",credentials:"omit"})
|
|
.then(function(r){return r.json()})
|
|
.then(function(j){
|
|
clearTimeout(ti);
|
|
var ok=!!(j&&j.code===200&&j.data);
|
|
if(!ok){__try(i+1);return}
|
|
try{localStorage.setItem("__v6probe",JSON.stringify({t:Date.now(),ok:true}))}catch(e){}
|
|
__showV6()})
|
|
.catch(function(){clearTimeout(ti);__try(i+1)})}
|
|
__try(0)}
|
|
function __reprobe(){try{localStorage.removeItem("__v6probe")}catch(e){}
|
|
var s=document.getElementById('st');if(s){s.textContent='正在重新检测 IPv6…';s.style.color='rgba(255,255,255,.45)';s.style.display='block'}
|
|
var n=document.getElementById('nt');if(n)n.style.display='none';
|
|
var c=document.getElementById('c6');if(c)c.style.display='';
|
|
__probe()}
|
|
function __forceV6(){try{localStorage.setItem("__v6probe",JSON.stringify({t:Date.now(),ok:true}))}catch(e){}
|
|
try{localStorage.setItem("__v6dest","v6")}catch(e){}
|
|
location.href=H.v6+"${back}"+location.search+location.hash}
|
|
try{var __c=localStorage.getItem("__v6dest");
|
|
if(__c){document.querySelectorAll(".card").forEach(function(c){if((__c==='v6'&&c.classList.contains("v6"))||(__c==='v4'&&c.classList.contains("v4"))){
|
|
c.style.borderColor=getComputedStyle(c).getPropertyValue("--c");
|
|
c.style.boxShadow="0 10px 28px rgba(0,0,0,.35)";
|
|
var b=c.querySelector(".badge");if(b){b.textContent="✓ 当前线路";b.style.background="#10b98122"}}})}}catch(e){}
|
|
__probe();
|
|
</script></body></html>`;
|
|
return new Response(html,{headers:{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store"}});
|
|
}
|
|
/* ==== IPV6PAGE END ==== */
|