login-gate: 退出标记只写本机真实存储(maternal-bridge 镜像接管时借同源 iframe),v26110610
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||
var VER = '26110608';
|
||||
var VER = '26110610';
|
||||
const $ = (s, c) => (c || document).querySelector(s);
|
||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||
|
||||
|
||||
@@ -15,8 +15,19 @@
|
||||
var m = ((location.hash || '') + '&' + (location.search || '')).match(new RegExp('[#?&]' + n + '=([^&#?]*)'));
|
||||
return m ? decodeURIComponent(m[1]) : '';
|
||||
}
|
||||
/* 11-07(消消乐 80d347e2 实测):maternal-bridge 会把 window.localStorage 换成落库的镜像,标记写进镜像会被同步到服务端 app_states,
|
||||
刷新首屏又读不到 → 卡在登录态。退出标记只放本机真实存储:本脚本先于 bridge 加载时当场拿住;bridge 已接管时借一个同源隐藏 iframe 的。 */
|
||||
var LS = (function () {
|
||||
try {
|
||||
if (!window.MaternalBridge) return window.localStorage;
|
||||
var f = document.createElement('iframe');
|
||||
f.style.display = 'none'; f.setAttribute('aria-hidden', 'true'); f.src = 'about:blank';
|
||||
(document.body || document.documentElement).appendChild(f);
|
||||
return f.contentWindow.localStorage;
|
||||
} catch (e) { try { return window.localStorage; } catch (e2) { return null; } }
|
||||
})();
|
||||
var O = param('openid'), out = false;
|
||||
try { out = !!O && localStorage.getItem(KEY) === O; } catch (e) {}
|
||||
try { out = !!O && LS.getItem(KEY) === O; } catch (e) {}
|
||||
var root = document.documentElement;
|
||||
if (out) root.classList.add('mb-out');
|
||||
|
||||
@@ -25,7 +36,7 @@
|
||||
openid: O,
|
||||
set: function (v) {
|
||||
G.out = !!v;
|
||||
try { if (v) localStorage.setItem(KEY, O); else localStorage.removeItem(KEY); } catch (e) {}
|
||||
try { if (v) LS.setItem(KEY, O); else LS.removeItem(KEY); } catch (e) {}
|
||||
root.classList.toggle('mb-out', !!v);
|
||||
},
|
||||
login: function () {
|
||||
|
||||
Reference in New Issue
Block a user