v-fixed43: IPv6探测改4443端口(家宽封443导致有IPv6也误判),双端口依次探测+仍要使用IPv6按钮
This commit is contained in:
1 parent
aa7652118c
commit
f3eacaad08
2 files changed
+20
-12
No files matched your search
+19
-11
@@ -45,7 +45,7 @@ background:rgba(239,68,68,.15);color:#fca5a5;font-size:13px;cursor:pointer;trans
|
||||
<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></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>
|
||||
@@ -63,7 +63,7 @@ background:rgba(239,68,68,.15);color:#fca5a5;font-size:13px;cursor:pointer;trans
|
||||
<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"};
|
||||
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';
|
||||
@@ -86,26 +86,34 @@ 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 模式拿真实状态并校验响应体,
|
||||
// 只有真正连通并返回合法 JSON 才算支持 IPv6
|
||||
// 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("https://tv6.88531.cn/api/license-config?_="+Date.now(),
|
||||
{mode:"cors",signal:c.signal,cache:"no-store",credentials:"omit"})
|
||||
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);
|
||||
try{localStorage.setItem("__v6probe",JSON.stringify({t:Date.now(),ok:ok}))}catch(e){}
|
||||
ok?__showV6():__hideV6()})
|
||||
.catch(function(){clearTimeout(ti);
|
||||
try{localStorage.setItem("__v6probe",JSON.stringify({t:Date.now(),ok:false}))}catch(e){}
|
||||
__hideV6()})}
|
||||
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");
|
||||
|
||||
@@ -223,7 +223,7 @@ function writeChecked(p, s) {
|
||||
// 清理旧版探针(V1 自动跳转 / V2 旧版)
|
||||
s = s.replace(/\/\*V6-PROBE-V[12]\*\/.*?catch\(e\)\{\}\s*/s, "");
|
||||
if (s.includes("/*V6-PROBE-V1*/")) { log("v6-probe: skip (already)"); return; }
|
||||
const probe = '/*V6-PROBE-V1*/try{if("tv.88531.cn"===location.hostname){var __v6k="__v6dest";var __v6t=+(localStorage.getItem(__v6k+"_t")||0);if(Date.now()-__v6t>21600000){localStorage.setItem(__v6k+"_t",Date.now());var __v6c=new AbortController();var __v6ti=setTimeout(function(){__v6c.abort()},1500);fetch("https://tv6.88531.cn/api/license-config",{mode:"no-cors",signal:__v6c.signal,cache:"no-store"}).then(function(){clearTimeout(__v6ti);location.replace("https://tv6.88531.cn"+location.pathname+location.search+location.hash)}).catch(function(){clearTimeout(__v6ti)})}}}catch(e){} ';
|
||||
const probe = '/*V6-PROBE-V1*/try{if("tv.88531.cn"===location.hostname){var __v6k="__v6dest";var __v6t=+(localStorage.getItem(__v6k+"_t")||0);if(Date.now()-__v6t>21600000){localStorage.setItem(__v6k+"_t",Date.now());var __v6c=new AbortController();var __v6ti=setTimeout(function(){__v6c.abort()},1500);fetch("https://tv6.88531.cn:4443/api/license-config",{mode:"no-cors",signal:__v6c.signal,cache:"no-store"}).then(function(){clearTimeout(__v6ti);location.replace("https://tv6.88531.cn:4443"+location.pathname+location.search+location.hash)}).catch(function(){clearTimeout(__v6ti)})}}}catch(e){} ';
|
||||
writeChecked(target, probe + s);
|
||||
log("v6-probe: injected into", target);
|
||||
})();
|
||||
|
||||
Reference in new issue
Block a user