prts-moonlit 1.0.3 → 1.0.4

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
@@ -1053,7 +1053,7 @@ document.addEventListener('pointerdown',function(){ac()},{once:true});
1053
1053
  var BASE='https://textdb.dev/api/data/prts-acct-';
1054
1054
  var LS='whale.acct',LT='whale.sync.t';
1055
1055
  var acct=null;try{acct=JSON.parse(localStorage.getItem(LS)||'null')}catch(e){}
1056
- var _si=localStorage.setItem.bind(localStorage),_app=0,pq=0,box=null,_dirty=0;
1056
+ var _si=localStorage.setItem.bind(localStorage),_app=0,pq=0,box=null,_dirty=0,lastSnap=null;
1057
1057
 
1058
1058
  function sha(msg){
1059
1059
  function r(v,n){return (v>>>n)|(v<<(32-n));}
@@ -1083,28 +1083,29 @@ document.addEventListener('pointerdown',function(){ac()},{once:true});
1083
1083
  }
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
+ function wxhr(u,b,cb){try{var x=new XMLHttpRequest();x.open('POST',u,true);x.setRequestHeader('Content-Type','text/plain');x.onload=x.onerror=x.ontimeout=function(){if(cb)cb()};x.send(b);}catch(e){if(cb)cb();}}
1087
+ function canon(){var a=[];for(var i=0;i<TK.length;i++)a.push(TK[i]+'='+localStorage.getItem(TK[i]));return a.join('|');}
1086
1088
  function st(m){if(box&&box.st)box.st.textContent=m;}
1087
1089
  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
1090
  function apply(rb){
1089
1091
  _app=1;try{for(var k in rb.data){_si(k,rb.data[k]);}}finally{_app=0;}
1090
- _si(LT,String(rb.t||Date.now()));
1092
+ _si(LT,String(rb.t||Date.now()));lastSnap=canon();
1091
1093
  st('✔ 已从云端同步 '+clock()+',即将刷新…');
1092
1094
  setTimeout(function(){location.reload();},350);
1093
1095
  }
1094
- function push(){
1096
+ function push(ry){
1095
1097
  if(!acct||!acct.k)return;
1096
- _dirty=0;var t=Date.now();_si(LT,String(t));
1098
+ if(!ry)window.__pv=0;
1099
+ _dirty=0;var t=Date.now();_si(LT,String(t));lastSnap=canon();
1097
1100
  st('↻ 同步中…');
1098
- fetch(url(),{method:'POST',mode:'no-cors',body:JSON.stringify({v:1,u:acct.u,t:t,data:snap()})})
1099
- .then(function(){st('✔ 已上传 · 后台校验…');setTimeout(function(){verify(t)},600);})
1100
- .catch(function(){st('⚠ 云同步暂不可用(可用存档码手动搬)');});
1101
+ wxhr(url(),JSON.stringify({v:1,u:acct.u,t:t,data:snap()}),function(){st('✔ 已上传 · 后台校验…');setTimeout(function(){verify(t)},600);});
1101
1102
  }
1102
1103
  function verify(t){
1103
1104
  fetch(url()+'?ts='+Date.now(),{cache:'no-store'}).then(function(r){return r.text()}).then(function(x){
1104
1105
  x=(x||'').replace(/=$/,'');
1105
1106
  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();},800);}
1107
- else{st('⚠ 云端回读不一致,稍后自动重试');}
1107
+ if(!window.__pv){window.__pv=1;setTimeout(function(){push(1);},800);}
1108
+ else{window.__pv=0;st('⚠ 上传好像没送达(此浏览器限制跨域)——数据还在本机,可换 Safari 或用存档码');}
1108
1109
  }).catch(function(){st('⚠ 校验失败(可能网络受限)');});
1109
1110
  }
1110
1111
  function pull(manual){
@@ -1209,7 +1210,7 @@ document.addEventListener('pointerdown',function(){ac()},{once:true});
1209
1210
  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
1211
  window.addEventListener('pagehide',function(){
1211
1212
  if(acct&&acct.k&&_dirty){try{_dirty=0;_si(LT,String(Date.now()));
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
+ var x=new XMLHttpRequest();x.open('POST',url(),false);x.setRequestHeader('Content-Type','text/plain');x.send(JSON.stringify({v:1,u:acct.u,t:Date.now(),data:snap()}));}catch(e){}}
1213
1214
  });
1214
1215
  document.addEventListener('visibilitychange',function(){if(!document.hidden&&acct&&acct.k&&!wrap.classList.contains('on'))pull(false);});
1215
1216
  setInterval(function(){if(!document.hidden&&acct&&acct.k&&!wrap.classList.contains('on'))pull(false);},15000);
@@ -1219,9 +1220,11 @@ document.addEventListener('pointerdown',function(){ac()},{once:true});
1219
1220
  else{btn.textContent='@';btn.style.cssText='position:fixed;right:14px;bottom:60px;z-index:120;width:38px;height:38px;display:flex;align-items:center;justify-content:center;border:2px solid #4cc9ff;background:rgba(7,12,24,.92);color:#4cc9ff;font-size:17px;cursor:pointer;user-select:none;box-shadow:3px 3px 0 rgba(0,0,0,.45)';document.body.appendChild(btn);}
1220
1221
  btn.id='acctBtn';btn.title='云存档';
1221
1222
  if(acct)btn.style.background='rgba(76,201,255,.28)';
1223
+ lastSnap=canon();
1222
1224
  btn.addEventListener('click',open);
1225
+ setInterval(function(){if(acct&&acct.k){var c=canon();if(c!==lastSnap){lastSnap=c;clearTimeout(pq);pq=setTimeout(push,900);}}},2000);
1223
1226
  if(acct&&acct.k){setTimeout(function(){pull(false);},250);}
1224
- window.__shaT=sha;
1227
+ window.__shaT=sha;window.__pushT=push;window.__pullT=pull;window.__canonT=canon;
1225
1228
  })();
1226
1229
  </script>
1227
1230
  </body>
package/index.html CHANGED
@@ -2767,7 +2767,7 @@ boot();
2767
2767
  var BASE='https://textdb.dev/api/data/prts-acct-';
2768
2768
  var LS='whale.acct',LT='whale.sync.t';
2769
2769
  var acct=null;try{acct=JSON.parse(localStorage.getItem(LS)||'null')}catch(e){}
2770
- var _si=localStorage.setItem.bind(localStorage),_app=0,pq=0,box=null,_dirty=0;
2770
+ var _si=localStorage.setItem.bind(localStorage),_app=0,pq=0,box=null,_dirty=0,lastSnap=null;
2771
2771
 
2772
2772
  function sha(msg){
2773
2773
  function r(v,n){return (v>>>n)|(v<<(32-n));}
@@ -2797,28 +2797,29 @@ boot();
2797
2797
  }
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
+ function wxhr(u,b,cb){try{var x=new XMLHttpRequest();x.open('POST',u,true);x.setRequestHeader('Content-Type','text/plain');x.onload=x.onerror=x.ontimeout=function(){if(cb)cb()};x.send(b);}catch(e){if(cb)cb();}}
2801
+ function canon(){var a=[];for(var i=0;i<TK.length;i++)a.push(TK[i]+'='+localStorage.getItem(TK[i]));return a.join('|');}
2800
2802
  function st(m){if(box&&box.st)box.st.textContent=m;}
2801
2803
  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
2804
  function apply(rb){
2803
2805
  _app=1;try{for(var k in rb.data){_si(k,rb.data[k]);}}finally{_app=0;}
2804
- _si(LT,String(rb.t||Date.now()));
2806
+ _si(LT,String(rb.t||Date.now()));lastSnap=canon();
2805
2807
  st('✔ 已从云端同步 '+clock()+',即将刷新…');
2806
2808
  setTimeout(function(){location.reload();},350);
2807
2809
  }
2808
- function push(){
2810
+ function push(ry){
2809
2811
  if(!acct||!acct.k)return;
2810
- _dirty=0;var t=Date.now();_si(LT,String(t));
2812
+ if(!ry)window.__pv=0;
2813
+ _dirty=0;var t=Date.now();_si(LT,String(t));lastSnap=canon();
2811
2814
  st('↻ 同步中…');
2812
- fetch(url(),{method:'POST',mode:'no-cors',body:JSON.stringify({v:1,u:acct.u,t:t,data:snap()})})
2813
- .then(function(){st('✔ 已上传 · 后台校验…');setTimeout(function(){verify(t)},600);})
2814
- .catch(function(){st('⚠ 云同步暂不可用(可用存档码手动搬)');});
2815
+ wxhr(url(),JSON.stringify({v:1,u:acct.u,t:t,data:snap()}),function(){st('✔ 已上传 · 后台校验…');setTimeout(function(){verify(t)},600);});
2815
2816
  }
2816
2817
  function verify(t){
2817
2818
  fetch(url()+'?ts='+Date.now(),{cache:'no-store'}).then(function(r){return r.text()}).then(function(x){
2818
2819
  x=(x||'').replace(/=$/,'');
2819
2820
  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();},800);}
2821
- else{st('⚠ 云端回读不一致,稍后自动重试');}
2821
+ if(!window.__pv){window.__pv=1;setTimeout(function(){push(1);},800);}
2822
+ else{window.__pv=0;st('⚠ 上传好像没送达(此浏览器限制跨域)——数据还在本机,可换 Safari 或用存档码');}
2822
2823
  }).catch(function(){st('⚠ 校验失败(可能网络受限)');});
2823
2824
  }
2824
2825
  function pull(manual){
@@ -2923,7 +2924,7 @@ boot();
2923
2924
  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
2925
  window.addEventListener('pagehide',function(){
2925
2926
  if(acct&&acct.k&&_dirty){try{_dirty=0;_si(LT,String(Date.now()));
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
+ var x=new XMLHttpRequest();x.open('POST',url(),false);x.setRequestHeader('Content-Type','text/plain');x.send(JSON.stringify({v:1,u:acct.u,t:Date.now(),data:snap()}));}catch(e){}}
2927
2928
  });
2928
2929
  document.addEventListener('visibilitychange',function(){if(!document.hidden&&acct&&acct.k&&!wrap.classList.contains('on'))pull(false);});
2929
2930
  setInterval(function(){if(!document.hidden&&acct&&acct.k&&!wrap.classList.contains('on'))pull(false);},15000);
@@ -2933,9 +2934,11 @@ boot();
2933
2934
  else{btn.textContent='@';btn.style.cssText='position:fixed;right:14px;bottom:60px;z-index:120;width:38px;height:38px;display:flex;align-items:center;justify-content:center;border:2px solid #4cc9ff;background:rgba(7,12,24,.92);color:#4cc9ff;font-size:17px;cursor:pointer;user-select:none;box-shadow:3px 3px 0 rgba(0,0,0,.45)';document.body.appendChild(btn);}
2934
2935
  btn.id='acctBtn';btn.title='云存档';
2935
2936
  if(acct)btn.style.background='rgba(76,201,255,.28)';
2937
+ lastSnap=canon();
2936
2938
  btn.addEventListener('click',open);
2939
+ setInterval(function(){if(acct&&acct.k){var c=canon();if(c!==lastSnap){lastSnap=c;clearTimeout(pq);pq=setTimeout(push,900);}}},2000);
2937
2940
  if(acct&&acct.k){setTimeout(function(){pull(false);},250);}
2938
- window.__shaT=sha;
2941
+ window.__shaT=sha;window.__pushT=push;window.__pullT=pull;window.__canonT=canon;
2939
2942
  })();
2940
2943
  </script>
2941
2944
  </body>
package/ledger.html CHANGED
@@ -1013,7 +1013,7 @@ window.LEDGER_BACKUP = [];
1013
1013
  var BASE='https://textdb.dev/api/data/prts-acct-';
1014
1014
  var LS='whale.acct',LT='whale.sync.t';
1015
1015
  var acct=null;try{acct=JSON.parse(localStorage.getItem(LS)||'null')}catch(e){}
1016
- var _si=localStorage.setItem.bind(localStorage),_app=0,pq=0,box=null,_dirty=0;
1016
+ var _si=localStorage.setItem.bind(localStorage),_app=0,pq=0,box=null,_dirty=0,lastSnap=null;
1017
1017
 
1018
1018
  function sha(msg){
1019
1019
  function r(v,n){return (v>>>n)|(v<<(32-n));}
@@ -1043,28 +1043,29 @@ window.LEDGER_BACKUP = [];
1043
1043
  }
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
+ function wxhr(u,b,cb){try{var x=new XMLHttpRequest();x.open('POST',u,true);x.setRequestHeader('Content-Type','text/plain');x.onload=x.onerror=x.ontimeout=function(){if(cb)cb()};x.send(b);}catch(e){if(cb)cb();}}
1047
+ function canon(){var a=[];for(var i=0;i<TK.length;i++)a.push(TK[i]+'='+localStorage.getItem(TK[i]));return a.join('|');}
1046
1048
  function st(m){if(box&&box.st)box.st.textContent=m;}
1047
1049
  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
1050
  function apply(rb){
1049
1051
  _app=1;try{for(var k in rb.data){_si(k,rb.data[k]);}}finally{_app=0;}
1050
- _si(LT,String(rb.t||Date.now()));
1052
+ _si(LT,String(rb.t||Date.now()));lastSnap=canon();
1051
1053
  st('✔ 已从云端同步 '+clock()+',即将刷新…');
1052
1054
  setTimeout(function(){location.reload();},350);
1053
1055
  }
1054
- function push(){
1056
+ function push(ry){
1055
1057
  if(!acct||!acct.k)return;
1056
- _dirty=0;var t=Date.now();_si(LT,String(t));
1058
+ if(!ry)window.__pv=0;
1059
+ _dirty=0;var t=Date.now();_si(LT,String(t));lastSnap=canon();
1057
1060
  st('↻ 同步中…');
1058
- fetch(url(),{method:'POST',mode:'no-cors',body:JSON.stringify({v:1,u:acct.u,t:t,data:snap()})})
1059
- .then(function(){st('✔ 已上传 · 后台校验…');setTimeout(function(){verify(t)},600);})
1060
- .catch(function(){st('⚠ 云同步暂不可用(可用存档码手动搬)');});
1061
+ wxhr(url(),JSON.stringify({v:1,u:acct.u,t:t,data:snap()}),function(){st('✔ 已上传 · 后台校验…');setTimeout(function(){verify(t)},600);});
1061
1062
  }
1062
1063
  function verify(t){
1063
1064
  fetch(url()+'?ts='+Date.now(),{cache:'no-store'}).then(function(r){return r.text()}).then(function(x){
1064
1065
  x=(x||'').replace(/=$/,'');
1065
1066
  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();},800);}
1067
- else{st('⚠ 云端回读不一致,稍后自动重试');}
1067
+ if(!window.__pv){window.__pv=1;setTimeout(function(){push(1);},800);}
1068
+ else{window.__pv=0;st('⚠ 上传好像没送达(此浏览器限制跨域)——数据还在本机,可换 Safari 或用存档码');}
1068
1069
  }).catch(function(){st('⚠ 校验失败(可能网络受限)');});
1069
1070
  }
1070
1071
  function pull(manual){
@@ -1169,7 +1170,7 @@ window.LEDGER_BACKUP = [];
1169
1170
  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
1171
  window.addEventListener('pagehide',function(){
1171
1172
  if(acct&&acct.k&&_dirty){try{_dirty=0;_si(LT,String(Date.now()));
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
+ var x=new XMLHttpRequest();x.open('POST',url(),false);x.setRequestHeader('Content-Type','text/plain');x.send(JSON.stringify({v:1,u:acct.u,t:Date.now(),data:snap()}));}catch(e){}}
1173
1174
  });
1174
1175
  document.addEventListener('visibilitychange',function(){if(!document.hidden&&acct&&acct.k&&!wrap.classList.contains('on'))pull(false);});
1175
1176
  setInterval(function(){if(!document.hidden&&acct&&acct.k&&!wrap.classList.contains('on'))pull(false);},15000);
@@ -1179,9 +1180,11 @@ window.LEDGER_BACKUP = [];
1179
1180
  else{btn.textContent='@';btn.style.cssText='position:fixed;right:14px;bottom:60px;z-index:120;width:38px;height:38px;display:flex;align-items:center;justify-content:center;border:2px solid #4cc9ff;background:rgba(7,12,24,.92);color:#4cc9ff;font-size:17px;cursor:pointer;user-select:none;box-shadow:3px 3px 0 rgba(0,0,0,.45)';document.body.appendChild(btn);}
1180
1181
  btn.id='acctBtn';btn.title='云存档';
1181
1182
  if(acct)btn.style.background='rgba(76,201,255,.28)';
1183
+ lastSnap=canon();
1182
1184
  btn.addEventListener('click',open);
1185
+ setInterval(function(){if(acct&&acct.k){var c=canon();if(c!==lastSnap){lastSnap=c;clearTimeout(pq);pq=setTimeout(push,900);}}},2000);
1183
1186
  if(acct&&acct.k){setTimeout(function(){pull(false);},250);}
1184
- window.__shaT=sha;
1187
+ window.__shaT=sha;window.__pushT=push;window.__pullT=pull;window.__canonT=canon;
1185
1188
  })();
1186
1189
  </script>
1187
1190
  </body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prts-moonlit",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "ARKNIGHTS x P3R Moonlit PRTS terminal (personal toy site)",
5
5
  "license": "MIT"
6
6
  }