Files
mama-box/js/gch/brand.js

23 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* 11-02 首页品牌露出(用户定 4 处都要,默认加载;?brand=0 关掉)
用户:「首页缺少品牌性露出(兜爸心选),增加一些品牌曝光,但不要太过,要合理」
原则:不加横幅/弹窗/开屏,只在「内容是谁做的」这种自然位置署名 —— 共 4 处:
① 页底落款(logo + 一句话)② 专属福利「兜爸出品」③ 测一测「兜爸原创」④ 广场投稿卡「兜爸心选官方征集」 */
(function () {
var CHIP = function (t) { return '<span class="br-chip"><i>兜</i>' + t + '</span>'; };
// ① 页底落款
var hb = document.getElementById('homeBody');
if (hb) {
var f = document.createElement('div'); f.className = 'br-foot';
f.innerHTML = '<img src="assets/img/brand-logo-c.png" alt="兜爸心选"><div class="br-l">陪你从孕期到育儿的每一天</div>';
hb.appendChild(f);
}
// ② 专属福利标题旁
[].forEach.call(document.querySelectorAll('#homeBody .sh-title'), function (h) { if (/专属福利/.test(h.textContent) && !h.querySelector('.br-chip')) h.insertAdjacentHTML('beforeend', CHIP('兜爸出品')); });
// ③④ 广场 / 测一测是异步渲染的,等它们出来再加
var n = 0, t = setInterval(function () {
var q = document.querySelector('.g6-qh'); /* ④ 投稿卡文案直接写在 js/gch/v4.js(卡堆会重绘) */
if (q && !q.querySelector('.br-chip')) { var sm = q.querySelector('small'); if (sm) sm.remove(); q.insertAdjacentHTML('beforeend', CHIP('兜爸原创')); }
if (q || ++n > 40) clearInterval(t);
}, 300);
})();