prts-moonlit 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/gacha.html CHANGED
@@ -1084,32 +1084,32 @@ document.addEventListener('pointerdown',function(){ac()},{once:true});
1084
1084
  function snap(){var d={};for(var i=0;i<TK.length;i++){var v=localStorage.getItem(TK[i]);if(v!==null)d[TK[i]]=v;}return d;}
1085
1085
  function url(){return BASE+acct.k;}
1086
1086
  function st(m){if(box&&box.st)box.st.textContent=m;}
1087
- function clock(){var d=new Date();function p(n){return(n<10?'0':'')+n}return p(d.getHours())+':'+p(d.getMinutes());}
1087
+ function clock(){var d=new Date();function p(n){return(n<10?'0':'')+n}return p(d.getHours())+':'+p(d.getMinutes())+':'+p(d.getSeconds());}
1088
1088
  function apply(rb){
1089
1089
  _app=1;try{for(var k in rb.data){_si(k,rb.data[k]);}}finally{_app=0;}
1090
1090
  _si(LT,String(rb.t||Date.now()));
1091
1091
  st('✔ 已从云端同步 '+clock()+',即将刷新…');
1092
- setTimeout(function(){location.reload();},800);
1092
+ setTimeout(function(){location.reload();},350);
1093
1093
  }
1094
1094
  function push(){
1095
1095
  if(!acct||!acct.k)return;
1096
1096
  _dirty=0;var t=Date.now();_si(LT,String(t));
1097
1097
  st('↻ 同步中…');
1098
1098
  fetch(url(),{method:'POST',mode:'no-cors',body:JSON.stringify({v:1,u:acct.u,t:t,data:snap()})})
1099
- .then(function(){setTimeout(function(){verify(t)},1800);})
1099
+ .then(function(){st('✔ 已上传 · 后台校验…');setTimeout(function(){verify(t)},600);})
1100
1100
  .catch(function(){st('⚠ 云同步暂不可用(可用存档码手动搬)');});
1101
1101
  }
1102
1102
  function verify(t){
1103
- fetch(url()+'?ts='+Date.now()).then(function(r){return r.text()}).then(function(x){
1103
+ fetch(url()+'?ts='+Date.now(),{cache:'no-store'}).then(function(r){return r.text()}).then(function(x){
1104
1104
  x=(x||'').replace(/=$/,'');
1105
1105
  try{var rb=JSON.parse(x);if(rb.t===t){st('✔ 已同步 '+clock());return;}}catch(e){}
1106
- if(!window.__pv){window.__pv=1;setTimeout(function(){window.__pv=0;push();},1500);}
1106
+ if(!window.__pv){window.__pv=1;setTimeout(function(){window.__pv=0;push();},800);}
1107
1107
  else{st('⚠ 云端回读不一致,稍后自动重试');}
1108
1108
  }).catch(function(){st('⚠ 校验失败(可能网络受限)');});
1109
1109
  }
1110
1110
  function pull(manual){
1111
1111
  if(!acct||!acct.k)return;
1112
- fetch(url()+'?ts='+Date.now()).then(function(r){return r.text()}).then(function(x){
1112
+ fetch(url()+'?ts='+Date.now(),{cache:'no-store'}).then(function(r){return r.text()}).then(function(x){
1113
1113
  x=(x||'').replace(/=$/,'');
1114
1114
  if(!x){if(manual)st('☁ 云端暂时没有存档——点「立即同步」上传本机数据');return;}
1115
1115
  var rb;try{rb=JSON.parse(x)}catch(e){st('⚠ 云端数据格式异常');return;}
@@ -1169,11 +1169,11 @@ document.addEventListener('pointerdown',function(){ac()},{once:true});
1169
1169
  st('✦ 仓库已创建,正在上传本机数据…');render();push();return;
1170
1170
  }
1171
1171
  st('↻ 查找云端仓库…');
1172
- fetch(BASE+k+'?ts='+Date.now()).then(function(r){return r.text()}).then(function(x){
1172
+ fetch(BASE+k+'?ts='+Date.now(),{cache:'no-store'}).then(function(r){return r.text()}).then(function(x){
1173
1173
  x=(x||'').replace(/=$/,'');
1174
1174
  if(x&&x.length>2){
1175
1175
  acct={u:u,k:k};_si(LS,JSON.stringify(acct));
1176
- var rb=null;try{rb=JSON.parse(x)}catch(e){}
1176
+ var rb=null;try{rb=JSON.parse(x)}catch(e){}if(!rb){acct=null;localStorage.removeItem(LS);st('⚠ 云端数据异常(可能被误写入过)——没敢覆盖,联系鲸鲸');return;}
1177
1177
  if(rb&&(rb.t||0)>Number(localStorage.getItem(LT)||0)){apply(rb);}
1178
1178
  else{_si(LT,String((rb&&rb.t)||Date.now()));st('✔ 已登录,云端仓库已连接 '+clock());render();}
1179
1179
  }else{
@@ -1206,12 +1206,13 @@ document.addEventListener('pointerdown',function(){ac()},{once:true});
1206
1206
  }
1207
1207
  function open(){render();wrap.classList.add('on')}
1208
1208
  var _orig=localStorage.setItem;
1209
- localStorage.setItem=function(k,v){_orig.call(localStorage,k,v);if(!_app&&acct&&acct.k&&TK.indexOf(k)>=0&&k!==LT){_dirty=1;clearTimeout(pq);pq=setTimeout(push,2200);}};
1209
+ localStorage.setItem=function(k,v){_orig.call(localStorage,k,v);if(!_app&&acct&&acct.k&&TK.indexOf(k)>=0&&k!==LT){_dirty=1;clearTimeout(pq);pq=setTimeout(push,900);}};
1210
1210
  window.addEventListener('pagehide',function(){
1211
1211
  if(acct&&acct.k&&_dirty){try{_dirty=0;_si(LT,String(Date.now()));
1212
1212
  fetch(url(),{method:'POST',mode:'no-cors',keepalive:true,body:JSON.stringify({v:1,u:acct.u,t:Date.now(),data:snap()})});}catch(e){}}
1213
1213
  });
1214
- document.addEventListener('visibilitychange',function(){if(!document.hidden&&acct&&acct.k){pull(false);}});
1214
+ document.addEventListener('visibilitychange',function(){if(!document.hidden&&acct&&acct.k&&!wrap.classList.contains('on'))pull(false);});
1215
+ setInterval(function(){if(!document.hidden&&acct&&acct.k&&!wrap.classList.contains('on'))pull(false);},15000);
1215
1216
  var btn=document.createElement('div');
1216
1217
  var ci=document.querySelector('.corner-ics');
1217
1218
  if(ci){btn.className='ci';btn.textContent='@';ci.appendChild(btn);}
@@ -1219,7 +1220,7 @@ document.addEventListener('pointerdown',function(){ac()},{once:true});
1219
1220
  btn.id='acctBtn';btn.title='云存档';
1220
1221
  if(acct)btn.style.background='rgba(76,201,255,.28)';
1221
1222
  btn.addEventListener('click',open);
1222
- if(acct&&acct.k){setTimeout(function(){pull(false);},1600);}
1223
+ if(acct&&acct.k){setTimeout(function(){pull(false);},250);}
1223
1224
  window.__shaT=sha;
1224
1225
  })();
1225
1226
  </script>
package/index.html CHANGED
@@ -2798,32 +2798,32 @@ boot();
2798
2798
  function snap(){var d={};for(var i=0;i<TK.length;i++){var v=localStorage.getItem(TK[i]);if(v!==null)d[TK[i]]=v;}return d;}
2799
2799
  function url(){return BASE+acct.k;}
2800
2800
  function st(m){if(box&&box.st)box.st.textContent=m;}
2801
- function clock(){var d=new Date();function p(n){return(n<10?'0':'')+n}return p(d.getHours())+':'+p(d.getMinutes());}
2801
+ function clock(){var d=new Date();function p(n){return(n<10?'0':'')+n}return p(d.getHours())+':'+p(d.getMinutes())+':'+p(d.getSeconds());}
2802
2802
  function apply(rb){
2803
2803
  _app=1;try{for(var k in rb.data){_si(k,rb.data[k]);}}finally{_app=0;}
2804
2804
  _si(LT,String(rb.t||Date.now()));
2805
2805
  st('✔ 已从云端同步 '+clock()+',即将刷新…');
2806
- setTimeout(function(){location.reload();},800);
2806
+ setTimeout(function(){location.reload();},350);
2807
2807
  }
2808
2808
  function push(){
2809
2809
  if(!acct||!acct.k)return;
2810
2810
  _dirty=0;var t=Date.now();_si(LT,String(t));
2811
2811
  st('↻ 同步中…');
2812
2812
  fetch(url(),{method:'POST',mode:'no-cors',body:JSON.stringify({v:1,u:acct.u,t:t,data:snap()})})
2813
- .then(function(){setTimeout(function(){verify(t)},1800);})
2813
+ .then(function(){st('✔ 已上传 · 后台校验…');setTimeout(function(){verify(t)},600);})
2814
2814
  .catch(function(){st('⚠ 云同步暂不可用(可用存档码手动搬)');});
2815
2815
  }
2816
2816
  function verify(t){
2817
- fetch(url()+'?ts='+Date.now()).then(function(r){return r.text()}).then(function(x){
2817
+ fetch(url()+'?ts='+Date.now(),{cache:'no-store'}).then(function(r){return r.text()}).then(function(x){
2818
2818
  x=(x||'').replace(/=$/,'');
2819
2819
  try{var rb=JSON.parse(x);if(rb.t===t){st('✔ 已同步 '+clock());return;}}catch(e){}
2820
- if(!window.__pv){window.__pv=1;setTimeout(function(){window.__pv=0;push();},1500);}
2820
+ if(!window.__pv){window.__pv=1;setTimeout(function(){window.__pv=0;push();},800);}
2821
2821
  else{st('⚠ 云端回读不一致,稍后自动重试');}
2822
2822
  }).catch(function(){st('⚠ 校验失败(可能网络受限)');});
2823
2823
  }
2824
2824
  function pull(manual){
2825
2825
  if(!acct||!acct.k)return;
2826
- fetch(url()+'?ts='+Date.now()).then(function(r){return r.text()}).then(function(x){
2826
+ fetch(url()+'?ts='+Date.now(),{cache:'no-store'}).then(function(r){return r.text()}).then(function(x){
2827
2827
  x=(x||'').replace(/=$/,'');
2828
2828
  if(!x){if(manual)st('☁ 云端暂时没有存档——点「立即同步」上传本机数据');return;}
2829
2829
  var rb;try{rb=JSON.parse(x)}catch(e){st('⚠ 云端数据格式异常');return;}
@@ -2883,11 +2883,11 @@ boot();
2883
2883
  st('✦ 仓库已创建,正在上传本机数据…');render();push();return;
2884
2884
  }
2885
2885
  st('↻ 查找云端仓库…');
2886
- fetch(BASE+k+'?ts='+Date.now()).then(function(r){return r.text()}).then(function(x){
2886
+ fetch(BASE+k+'?ts='+Date.now(),{cache:'no-store'}).then(function(r){return r.text()}).then(function(x){
2887
2887
  x=(x||'').replace(/=$/,'');
2888
2888
  if(x&&x.length>2){
2889
2889
  acct={u:u,k:k};_si(LS,JSON.stringify(acct));
2890
- var rb=null;try{rb=JSON.parse(x)}catch(e){}
2890
+ var rb=null;try{rb=JSON.parse(x)}catch(e){}if(!rb){acct=null;localStorage.removeItem(LS);st('⚠ 云端数据异常(可能被误写入过)——没敢覆盖,联系鲸鲸');return;}
2891
2891
  if(rb&&(rb.t||0)>Number(localStorage.getItem(LT)||0)){apply(rb);}
2892
2892
  else{_si(LT,String((rb&&rb.t)||Date.now()));st('✔ 已登录,云端仓库已连接 '+clock());render();}
2893
2893
  }else{
@@ -2920,12 +2920,13 @@ boot();
2920
2920
  }
2921
2921
  function open(){render();wrap.classList.add('on')}
2922
2922
  var _orig=localStorage.setItem;
2923
- localStorage.setItem=function(k,v){_orig.call(localStorage,k,v);if(!_app&&acct&&acct.k&&TK.indexOf(k)>=0&&k!==LT){_dirty=1;clearTimeout(pq);pq=setTimeout(push,2200);}};
2923
+ localStorage.setItem=function(k,v){_orig.call(localStorage,k,v);if(!_app&&acct&&acct.k&&TK.indexOf(k)>=0&&k!==LT){_dirty=1;clearTimeout(pq);pq=setTimeout(push,900);}};
2924
2924
  window.addEventListener('pagehide',function(){
2925
2925
  if(acct&&acct.k&&_dirty){try{_dirty=0;_si(LT,String(Date.now()));
2926
2926
  fetch(url(),{method:'POST',mode:'no-cors',keepalive:true,body:JSON.stringify({v:1,u:acct.u,t:Date.now(),data:snap()})});}catch(e){}}
2927
2927
  });
2928
- document.addEventListener('visibilitychange',function(){if(!document.hidden&&acct&&acct.k){pull(false);}});
2928
+ document.addEventListener('visibilitychange',function(){if(!document.hidden&&acct&&acct.k&&!wrap.classList.contains('on'))pull(false);});
2929
+ setInterval(function(){if(!document.hidden&&acct&&acct.k&&!wrap.classList.contains('on'))pull(false);},15000);
2929
2930
  var btn=document.createElement('div');
2930
2931
  var ci=document.querySelector('.corner-ics');
2931
2932
  if(ci){btn.className='ci';btn.textContent='@';ci.appendChild(btn);}
@@ -2933,7 +2934,7 @@ boot();
2933
2934
  btn.id='acctBtn';btn.title='云存档';
2934
2935
  if(acct)btn.style.background='rgba(76,201,255,.28)';
2935
2936
  btn.addEventListener('click',open);
2936
- if(acct&&acct.k){setTimeout(function(){pull(false);},1600);}
2937
+ if(acct&&acct.k){setTimeout(function(){pull(false);},250);}
2937
2938
  window.__shaT=sha;
2938
2939
  })();
2939
2940
  </script>
package/ledger.html CHANGED
@@ -1044,32 +1044,32 @@ window.LEDGER_BACKUP = [];
1044
1044
  function snap(){var d={};for(var i=0;i<TK.length;i++){var v=localStorage.getItem(TK[i]);if(v!==null)d[TK[i]]=v;}return d;}
1045
1045
  function url(){return BASE+acct.k;}
1046
1046
  function st(m){if(box&&box.st)box.st.textContent=m;}
1047
- function clock(){var d=new Date();function p(n){return(n<10?'0':'')+n}return p(d.getHours())+':'+p(d.getMinutes());}
1047
+ function clock(){var d=new Date();function p(n){return(n<10?'0':'')+n}return p(d.getHours())+':'+p(d.getMinutes())+':'+p(d.getSeconds());}
1048
1048
  function apply(rb){
1049
1049
  _app=1;try{for(var k in rb.data){_si(k,rb.data[k]);}}finally{_app=0;}
1050
1050
  _si(LT,String(rb.t||Date.now()));
1051
1051
  st('✔ 已从云端同步 '+clock()+',即将刷新…');
1052
- setTimeout(function(){location.reload();},800);
1052
+ setTimeout(function(){location.reload();},350);
1053
1053
  }
1054
1054
  function push(){
1055
1055
  if(!acct||!acct.k)return;
1056
1056
  _dirty=0;var t=Date.now();_si(LT,String(t));
1057
1057
  st('↻ 同步中…');
1058
1058
  fetch(url(),{method:'POST',mode:'no-cors',body:JSON.stringify({v:1,u:acct.u,t:t,data:snap()})})
1059
- .then(function(){setTimeout(function(){verify(t)},1800);})
1059
+ .then(function(){st('✔ 已上传 · 后台校验…');setTimeout(function(){verify(t)},600);})
1060
1060
  .catch(function(){st('⚠ 云同步暂不可用(可用存档码手动搬)');});
1061
1061
  }
1062
1062
  function verify(t){
1063
- fetch(url()+'?ts='+Date.now()).then(function(r){return r.text()}).then(function(x){
1063
+ fetch(url()+'?ts='+Date.now(),{cache:'no-store'}).then(function(r){return r.text()}).then(function(x){
1064
1064
  x=(x||'').replace(/=$/,'');
1065
1065
  try{var rb=JSON.parse(x);if(rb.t===t){st('✔ 已同步 '+clock());return;}}catch(e){}
1066
- if(!window.__pv){window.__pv=1;setTimeout(function(){window.__pv=0;push();},1500);}
1066
+ if(!window.__pv){window.__pv=1;setTimeout(function(){window.__pv=0;push();},800);}
1067
1067
  else{st('⚠ 云端回读不一致,稍后自动重试');}
1068
1068
  }).catch(function(){st('⚠ 校验失败(可能网络受限)');});
1069
1069
  }
1070
1070
  function pull(manual){
1071
1071
  if(!acct||!acct.k)return;
1072
- fetch(url()+'?ts='+Date.now()).then(function(r){return r.text()}).then(function(x){
1072
+ fetch(url()+'?ts='+Date.now(),{cache:'no-store'}).then(function(r){return r.text()}).then(function(x){
1073
1073
  x=(x||'').replace(/=$/,'');
1074
1074
  if(!x){if(manual)st('☁ 云端暂时没有存档——点「立即同步」上传本机数据');return;}
1075
1075
  var rb;try{rb=JSON.parse(x)}catch(e){st('⚠ 云端数据格式异常');return;}
@@ -1129,11 +1129,11 @@ window.LEDGER_BACKUP = [];
1129
1129
  st('✦ 仓库已创建,正在上传本机数据…');render();push();return;
1130
1130
  }
1131
1131
  st('↻ 查找云端仓库…');
1132
- fetch(BASE+k+'?ts='+Date.now()).then(function(r){return r.text()}).then(function(x){
1132
+ fetch(BASE+k+'?ts='+Date.now(),{cache:'no-store'}).then(function(r){return r.text()}).then(function(x){
1133
1133
  x=(x||'').replace(/=$/,'');
1134
1134
  if(x&&x.length>2){
1135
1135
  acct={u:u,k:k};_si(LS,JSON.stringify(acct));
1136
- var rb=null;try{rb=JSON.parse(x)}catch(e){}
1136
+ var rb=null;try{rb=JSON.parse(x)}catch(e){}if(!rb){acct=null;localStorage.removeItem(LS);st('⚠ 云端数据异常(可能被误写入过)——没敢覆盖,联系鲸鲸');return;}
1137
1137
  if(rb&&(rb.t||0)>Number(localStorage.getItem(LT)||0)){apply(rb);}
1138
1138
  else{_si(LT,String((rb&&rb.t)||Date.now()));st('✔ 已登录,云端仓库已连接 '+clock());render();}
1139
1139
  }else{
@@ -1166,12 +1166,13 @@ window.LEDGER_BACKUP = [];
1166
1166
  }
1167
1167
  function open(){render();wrap.classList.add('on')}
1168
1168
  var _orig=localStorage.setItem;
1169
- localStorage.setItem=function(k,v){_orig.call(localStorage,k,v);if(!_app&&acct&&acct.k&&TK.indexOf(k)>=0&&k!==LT){_dirty=1;clearTimeout(pq);pq=setTimeout(push,2200);}};
1169
+ localStorage.setItem=function(k,v){_orig.call(localStorage,k,v);if(!_app&&acct&&acct.k&&TK.indexOf(k)>=0&&k!==LT){_dirty=1;clearTimeout(pq);pq=setTimeout(push,900);}};
1170
1170
  window.addEventListener('pagehide',function(){
1171
1171
  if(acct&&acct.k&&_dirty){try{_dirty=0;_si(LT,String(Date.now()));
1172
1172
  fetch(url(),{method:'POST',mode:'no-cors',keepalive:true,body:JSON.stringify({v:1,u:acct.u,t:Date.now(),data:snap()})});}catch(e){}}
1173
1173
  });
1174
- document.addEventListener('visibilitychange',function(){if(!document.hidden&&acct&&acct.k){pull(false);}});
1174
+ document.addEventListener('visibilitychange',function(){if(!document.hidden&&acct&&acct.k&&!wrap.classList.contains('on'))pull(false);});
1175
+ setInterval(function(){if(!document.hidden&&acct&&acct.k&&!wrap.classList.contains('on'))pull(false);},15000);
1175
1176
  var btn=document.createElement('div');
1176
1177
  var ci=document.querySelector('.corner-ics');
1177
1178
  if(ci){btn.className='ci';btn.textContent='@';ci.appendChild(btn);}
@@ -1179,7 +1180,7 @@ window.LEDGER_BACKUP = [];
1179
1180
  btn.id='acctBtn';btn.title='云存档';
1180
1181
  if(acct)btn.style.background='rgba(76,201,255,.28)';
1181
1182
  btn.addEventListener('click',open);
1182
- if(acct&&acct.k){setTimeout(function(){pull(false);},1600);}
1183
+ if(acct&&acct.k){setTimeout(function(){pull(false);},250);}
1183
1184
  window.__shaT=sha;
1184
1185
  })();
1185
1186
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prts-moonlit",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "ARKNIGHTS x P3R Moonlit PRTS terminal (personal toy site)",
5
5
  "license": "MIT"
6
6
  }