v26110416 UGC 总开关:孕妈广场+测一测+专题评论区按后台 ugcEnabled 显示,关着时广场/测试页回首页(js/ugc.js)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
deploy
2026-11-04 08:18:11 +00:00
parent ec23742458
commit 4e6166c7e6
11 changed files with 92 additions and 20 deletions

View File

@@ -68,10 +68,10 @@
function getJSON(u) { return fetch(u, { cache: 'no-cache' }).then(function (r) { if (!r.ok) throw r.status; return r.json(); }); }
function related(box) {
getJSON('../_shared/idx.json?v=26110257').then(function (idx) {
getJSON('../_shared/idx.json?v=26110416').then(function (idx) {
var me = null; idx.forEach(function (x) { if (x[0] === SLUG) me = x; });
var tag = me ? me[2] : '', h = 0; for (var i = 0; i < SLUG.length; i++) h = (h * 31 + SLUG.charCodeAt(i)) >>> 0;
var rest = idx.filter(function (x) { return x[0] !== SLUG; });
var rest = idx.filter(function (x) { return x[0] !== SLUG && (window.__mbUgc || ['ceshi', 'duiyou'].indexOf(x[0]) < 0); }); /* UGC 关着不推两个测试 */
var same = rest.filter(function (x) { return x[2] === tag; }).sort(function (a, b) { return b[3] - a[3]; });
/* 同类按热度取前几里轮换,凑不够 3 个用全站热门补 */
var pick = [], top = same.slice(0, 6);
@@ -175,9 +175,18 @@
}
fetch(API + '/comments?kind=topic&target=' + encodeURIComponent(SLUG) + (OID ? '&openid=' + encodeURIComponent(OID) : ''))
.then(function (r) { return r.json(); }).then(function (j) { if (j && j.code === 200) { RC = j.result; paint(); } }).catch(function () {});
getJSON('../_shared/cm/' + SLUG + '.json?v=26110257').then(function (d) { L = d.c || []; paint(); }).catch(function () { paint(); });
getJSON('../_shared/cm/' + SLUG + '.json?v=26110416').then(function (d) { L = d.c || []; paint(); }).catch(function () { paint(); });
}
function ugcReady() {
if (window.__mbUgcReady) return window.__mbUgcReady;
return new Promise(function (res) {
var u = document.createElement('script'); u.src = '../../js/ugc.js?v=26110416';
u.onload = function () { (window.__mbUgcReady || Promise.resolve(false)).then(res); };
u.onerror = function () { res(false); };
document.head.appendChild(u);
});
}
function extras(el) {
if (!SLUG || document.getElementById('tx-rel')) return;
if (!document.getElementById('tx-css')) { var s = document.createElement('style'); s.id = 'tx-css'; s.textContent = css2; document.head.appendChild(s); }
@@ -188,7 +197,8 @@
[a, b].forEach(function (x) { x.style.marginLeft = c.marginLeft; x.style.marginRight = c.marginRight; });
a.style.setProperty('--tt-c', c.getPropertyValue('--tt-c')); a.style.setProperty('--tt-bg', c.getPropertyValue('--tt-bg'));
b.style.setProperty('--tt-c', c.getPropertyValue('--tt-c')); b.style.setProperty('--tt-bg', c.getPropertyValue('--tt-bg'));
related(a); comments(b);
/* 11-04 UGC 总开关(js/ugc.js):评论区是用户内容,关着就不出;相关推荐等开关结果再排(关着不推测试) */
ugcReady().then(function (on) { related(a); if (on) comments(b); else b.remove(); });
}
function render(el, list, opt) {

View File

@@ -2,6 +2,8 @@
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<!-- 11-04 UGC 总开关关着时本页不展示,直接回首页(js/ugc.js) -->
<script src="../../js/ugc.js?v=26110416" data-guard></script>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover">
<meta name="format-detection" content="telephone=no">
<title>测一测你是什么样的妈妈?</title>

View File

@@ -2,6 +2,8 @@
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<!-- 11-04 UGC 总开关关着时本页不展示,直接回首页(js/ugc.js) -->
<script src="../../js/ugc.js?v=26110416" data-guard></script>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover">
<meta name="format-detection" content="telephone=no">
<title>测一测:你家准爸爸是哪种队友?</title>