bep40 commited on
Commit
cf2f9c7
·
verified ·
1 Parent(s): a5eda89

Add hash fragment article loader for Zalo browser

Browse files
Files changed (1) hide show
  1. static/app_v2.js +17 -0
static/app_v2.js CHANGED
@@ -256,6 +256,23 @@ async function loadCat(id){const el=document.getElementById('view-cat');el.inner
256
  fetch('/api/storage_status').then(r=>r.json()).then(j=>{if(!j.persistent){const home=document.getElementById('view-home');if(home){const w=document.createElement('div');w.className='storage-warn';w.innerHTML='⚠️ Persistent Storage chưa bật.';home.prepend(w)}}}).catch(()=>{});
257
 
258
  // === AUTO-OPEN SHARE LINKS (/s?url=... sets pending_article) ===
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  (function(){
260
  try{
261
  const pa=localStorage.getItem('pending_article');
 
256
  fetch('/api/storage_status').then(r=>r.json()).then(j=>{if(!j.persistent){const home=document.getElementById('view-home');if(home){const w=document.createElement('div');w.className='storage-warn';w.innerHTML='⚠️ Persistent Storage chưa bật.';home.prepend(w)}}}).catch(()=>{});
257
 
258
  // === AUTO-OPEN SHARE LINKS (/s?url=... sets pending_article) ===
259
+ // Hash fragment fallback: nếu localStorage không work (Zalo browser), đọc từ hash
260
+ (function(){
261
+ try{
262
+ var hash = window.location.hash;
263
+ if(hash && hash.length > 1){
264
+ var articleUrl = decodeURIComponent(hash.substring(1));
265
+ if(articleUrl.startsWith('http')){
266
+ // Clear hash để tránh reload
267
+ history.replaceState(null, '', window.location.pathname);
268
+ setTimeout(function(){
269
+ if(typeof readArticle==='function') readArticle(articleUrl);
270
+ }, 1500);
271
+ }
272
+ }
273
+ }catch(e){}
274
+ })();
275
+
276
  (function(){
277
  try{
278
  const pa=localStorage.getItem('pending_article');