login-gate.js 支持其他应用自定义要拦的按钮(MB_GATE_SEL / MB_GATE_IN),供 16 个孕期应用引用

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
deploy
2026-11-07 00:40:35 +00:00
parent 5f2db65aad
commit 42794d2ed9

View File

@@ -105,17 +105,23 @@
function page() {
if (document.getElementById('homeBody')) return 'home';
if (document.getElementById('wf')) return 'plaza';
return 'topic';
if (/\/topic\//.test(location.pathname)) return 'topic';
return 'other';
}
/* 其他应用(数胎动、体重……)引本文件时自己指定:
window.MB_GATE_SEL = '.save-btn,.add-record'; 点了要拦的按钮(CSS 选择器)
window.MB_GATE_IN = '.note-input'; 一聚焦就提示的输入框
或在自己的提交函数里:if (window.mbGate && mbGate.need()) return; */
function selFor(map, cus) { return window[cus] || map[page()] || ''; }
document.addEventListener('click', function (e) {
if (!G.out || !e.target.closest) return;
var s = SEL[page()];
var s = selFor(SEL, 'MB_GATE_SEL');
if (s && e.target.closest(s)) G.need(e);
}, true);
/* 评论输入框:一点进去就提示(别让人打完一段字才发现发不出去) */
document.addEventListener('focusin', function (e) {
if (!G.out || !e.target.matches) return;
var s = IN[page()];
var s = selFor(IN, 'MB_GATE_IN');
if (s && e.target.matches(s)) { e.target.blur(); prompt(); }
}, true);
})();