// ==UserScript== // @name 命盘智能分析(排盘结果页) // @namespace https://pcbz.iwzwh.com/ // @version 2.0.1 // @description 在 pcbz.iwzwh.com 排盘结果页自动分析八字:五行强弱/喜用神、十神格局、精确起运、神煞、大运、大白话解读、一键复制/导出。纯本地规则,不联网不上传。 // @author you // @match https://pcbz.iwzwh.com/* // @match https://*.iwzwh.com/* // @run-at document-idle // @grant none // @noframes // ==/UserScript== /* ============================================================================ * 命盘智能分析 · 共享核心引擎 bazi-core.js * 纯本地规则,无网络请求。暴露 window.__BaziCore * 包含:基础字典 / 节气与起运 / 五行力量 / 日主强弱 / 喜用神 / 十神 / * 格局 / 地支关系 / 神煞 / 大白话解读 / 大运 * ==========================================================================*/ (function (global) { 'use strict'; /* ---------- 0. 字典 ---------- */ const GAN = ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸']; const ZHI = ['子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥']; const GAN_WX = { 甲: '木', 乙: '木', 丙: '火', 丁: '火', 戊: '土', 己: '土', 庚: '金', 辛: '金', 壬: '水', 癸: '水' }; const GAN_YY = { 甲: 1, 乙: -1, 丙: 1, 丁: -1, 戊: 1, 己: -1, 庚: 1, 辛: -1, 壬: 1, 癸: -1 }; const ZHI_WX = { 子: '水', 丑: '土', 寅: '木', 卯: '木', 辰: '土', 巳: '火', 午: '火', 未: '土', 申: '金', 酉: '金', 戌: '土', 亥: '水' }; const ZHI_YY = { 子: 1, 丑: -1, 寅: 1, 卯: -1, 辰: 1, 巳: -1, 午: 1, 未: -1, 申: 1, 酉: -1, 戌: 1, 亥: -1 }; const ZHI_CANG = { 子: ['癸'], 丑: ['己', '癸', '辛'], 寅: ['甲', '丙', '戊'], 卯: ['乙'], 辰: ['戊', '乙', '癸'], 巳: ['丙', '庚', '戊'], 午: ['丁', '己'], 未: ['己', '丁', '乙'], 申: ['庚', '壬', '戊'], 酉: ['辛'], 戌: ['戊', '辛', '丁'], 亥: ['壬', '甲'] }; const CANG_WEIGHT = [1.0, 0.45, 0.25]; const SHENG = { 木: '火', 火: '土', 土: '金', 金: '水', 水: '木' }; const KE = { 木: '土', 土: '水', 水: '火', 火: '金', 金: '木' }; const SHENG_ME = { 木: '水', 火: '木', 土: '火', 金: '土', 水: '金' }; const KE_ME = { 木: '金', 火: '水', 土: '木', 金: '火', 水: '土' }; const ZHI_CHONG = { 子: '午', 午: '子', 丑: '未', 未: '丑', 寅: '申', 申: '寅', 卯: '酉', 酉: '卯', 辰: '戌', 戌: '辰', 巳: '亥', 亥: '巳' }; const ZHI_HE = { 子: '丑', 丑: '子', 寅: '亥', 亥: '寅', 卯: '戌', 戌: '卯', 辰: '酉', 酉: '辰', 巳: '申', 申: '巳', 午: '未', 未: '午' }; const ZHI_XING = { 寅: '巳', 巳: '申', 申: '寅', 丑: '戌', 戌: '未', 未: '丑', 子: '卯', 卯: '子', 辰: '辰', 午: '午', 酉: '酉', 亥: '亥' }; function relationToDay(dayWX, dayYY, oWX, oYY) { const same = dayYY === oYY; if (oWX === dayWX) return same ? '比肩' : '劫财'; if (SHENG[dayWX] === oWX) return same ? '食神' : '伤官'; if (KE[dayWX] === oWX) return same ? '偏财' : '正财'; if (KE_ME[dayWX] === oWX) return same ? '七杀' : '正官'; if (SHENG_ME[dayWX] === oWX) return same ? '偏印' : '正印'; return ''; } /* ---------- 1. 儒略日 & 节气 ---------- */ function toJD(y, m, d, hh, mm) { if (m <= 2) { y -= 1; m += 12; } const A = Math.floor(y / 100); const B = 2 - A + Math.floor(A / 4); const dayFrac = (hh + mm / 60) / 24; return Math.floor(365.25 * (y + 4716)) + Math.floor(30.6001 * (m + 1)) + d + dayFrac + B - 1524.5; } function sunLongitude(jd) { const T = (jd - 2451545.0) / 36525; let L0 = 280.46646 + 36000.76983 * T + 0.0003032 * T * T; L0 = ((L0 % 360) + 360) % 360; const M = (357.52911 + 35999.05029 * T - 0.0001537 * T * T) * Math.PI / 180; const C = (1.914602 - 0.004817 * T - 0.000014 * T * T) * Math.sin(M) + (0.019993 - 0.000101 * T) * Math.sin(2 * M) + 0.000289 * Math.sin(3 * M); const trueLong = L0 + C; const omega = (125.04 - 1934.136 * T) * Math.PI / 180; const lambda = trueLong - 0.00569 - 0.00478 * Math.sin(omega); return ((lambda % 360) + 360) % 360; } // 节气黄经(12 节) const JIE_LONG = [315, 345, 15, 45, 75, 105, 135, 165, 195, 225, 255, 285]; const JIE_NAME = ['立春', '惊蛰', '清明', '立夏', '芒种', '小暑', '立秋', '白露', '寒露', '立冬', '大雪', '小寒']; function jieTime(year, targetLong) { let jd = toJD(year, 1, 1, 0, 0), best = null, bestDiff = 1e9; for (let d = 0; d < 370; d += 0.5) { const cur = jd + d, lon = sunLongitude(cur); const diff = ((lon - targetLong + 540) % 360) - 180; if (Math.abs(diff) < bestDiff) { bestDiff = Math.abs(diff); best = cur; } } let t = best; for (let i = 0; i < 8; i++) { const lon = sunLongitude(t); const diff = ((lon - targetLong + 540) % 360) - 180; t -= diff / 0.9856; } return t; } /* ---------- 2. 取数:URL 优先,DOM 兜底 ---------- */ function parseFromURL() { let sp = new URLSearchParams(location.search); if (!sp.getAll('tg').length) { const hash = location.hash || ''; const qi = hash.indexOf('?'); if (qi >= 0) sp = new URLSearchParams(hash.slice(qi + 1)); } const tg = sp.getAll('tg'), dz = sp.getAll('dz'); if (tg.length < 4 || dz.length < 4) return null; const pillars = [0, 1, 2, 3].map(i => ({ gan: tg[i], zhi: dz[i] })); // 解析出生时间:solarTime 是年,月,日,时,分 五个重复参数 const st = sp.getAll('solarTime'); let birth = null; if (st.length >= 5) { birth = { year: +st[0], month: +st[1], day: +st[2], hour: +st[3], minute: +st[4] }; } return { pillars, sex: sp.get('sex') || '', name: sp.get('name') || '', birth, source: 'url', isLunar: sp.get('xls') === '1' }; } function parseFromDOM() { try { const cands = [...document.querySelectorAll('div,span,td,li')].filter(el => { const t = (el.textContent || '').trim(); return /^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]$/.test(t); }); if (cands.length >= 4) { const pillars = []; for (let i = 0; i < 4; i++) { const t = cands[i].textContent.trim(); pillars.push({ gan: t[0], zhi: t[1] }); } return { pillars, sex: '', name: '', birth: null, source: 'dom', isLunar: false }; } } catch (e) { } return null; } function getBazi() { return parseFromURL() || parseFromDOM() || null; } /* ---------- 3. 五行力量 / 日主强弱 / 喜用 ---------- */ const POS = ['年', '月', '日', '时']; const WEIGHT = { 年: 0.8, 月: 1.6, 日: 1.0, 时: 0.8 }; function analyze(bz) { const P = bz.pillars; const dayGan = P[2].gan, dayWX = GAN_WX[dayGan], dayYY = GAN_YY[dayGan]; const wx = { 木: 0, 火: 0, 土: 0, 金: 0, 水: 0 }; P.forEach((p, i) => { const w = WEIGHT[POS[i]]; wx[GAN_WX[p.gan]] += 1.0 * w; (ZHI_CANG[p.zhi] || []).forEach((g, ci) => { wx[GAN_WX[g]] += (CANG_WEIGHT[ci] || 0.2) * w; }); }); const total = Object.values(wx).reduce((a, b) => a + b, 0) || 1; const pct = {}; Object.keys(wx).forEach(k => pct[k] = +(wx[k] / total * 100).toFixed(1)); let help = 0, drain = 0; Object.keys(wx).forEach(k => { if (k === dayWX || SHENG_ME[dayWX] === k) help += wx[k]; else drain += wx[k]; }); const monthZhi = P[1].zhi, monthWX = ZHI_WX[monthZhi]; let mb = 1; if (monthWX === dayWX) mb = 1.3; else if (SHENG_ME[dayWX] === monthWX) mb = 1.15; else if (KE_ME[dayWX] === monthWX) mb = 0.8; help *= mb; const ratio = help / (help + drain); let strength, strengthLv; if (ratio >= 0.62) { strength = '偏旺'; strengthLv = 3; } else if (ratio >= 0.52) { strength = '中和偏旺'; strengthLv = 2; } else if (ratio >= 0.42) { strength = '中和偏弱'; strengthLv = 1; } else { strength = '偏弱'; strengthLv = 0; } let yongShen, jiShen, reason; if (strengthLv >= 2) { yongShen = [...new Set([SHENG[dayWX], KE[dayWX], KE_ME[dayWX]])]; jiShen = [...new Set([dayWX, SHENG_ME[dayWX]])]; reason = '日主偏旺,力量足但容易"自己扛太多",宜用食伤(发挥)、财(求实利)、官杀(约束规范)来疏导,不宜再一味加码比劫、印星。'; } else { yongShen = [...new Set([SHENG_ME[dayWX], dayWX])]; jiShen = [...new Set([KE[dayWX], KE_ME[dayWX], SHENG[dayWX]])]; reason = '日主偏弱,能量稍显不足,宜用印星(学习、贵人、靠山)和比劫(朋友、团队、自信)来帮身,不宜过度消耗。'; } // 十神 const shiShenCount = {}; const pillarSS = []; P.forEach((p, i) => { const ss = i === 2 ? '元男/元女' : relationToDay(dayWX, dayYY, GAN_WX[p.gan], GAN_YY[p.gan]); pillarSS.push(ss); if (i !== 2) shiShenCount[ss] = (shiShenCount[ss] || 0) + 1; const mg = ZHI_CANG[p.zhi][0]; const s2 = relationToDay(dayWX, dayYY, GAN_WX[mg], GAN_YY[mg]); shiShenCount['支·' + s2] = (shiShenCount['支·' + s2] || 0) + 1; }); // 格局 const monthMain = ZHI_CANG[monthZhi][0]; const gejuShen = relationToDay(dayWX, dayYY, GAN_WX[monthMain], GAN_YY[monthMain]); let geju; if (['正官', '七杀', '正财', '偏财', '正印', '偏印', '食神', '伤官'].includes(gejuShen)) { geju = gejuShen + '格'; } else { geju = '建禄/月劫格'; } // 地支关系 const rels = []; for (let i = 0; i < 4; i++) for (let j = i + 1; j < 4; j++) { const a = P[i].zhi, b = P[j].zhi; if (ZHI_CHONG[a] === b) rels.push(`${POS[i]}支${a}与${POS[j]}支${b}相冲`); if (ZHI_HE[a] === b) rels.push(`${POS[i]}支${a}与${POS[j]}支${b}六合`); if (ZHI_XING[a] === b || ZHI_XING[b] === a) rels.push(`${POS[i]}支${a}与${POS[j]}支${b}相刑`); } // 神煞 const shensha = computeShensha(P, dayGan, dayYY, dayWX, bz.sex); // 起运 & 大运 const qiyun = bz.birth ? computeQiyun(bz.birth, P, bz.sex) : null; // 解读 const readings = buildReadings(dayWX, dayGan, strengthLv, yongShen, jiShen, shiShenCount, geju, rels, shensha, qiyun); return { pillars: P, dayGan, dayWX, dayYY, wx, pct, strength, strengthLv, ratio: +(ratio * 100).toFixed(1), yongShen, jiShen, reason, shiShenCount, pillarSS, geju, rels, shensha, qiyun, readings, bz }; } /* ---------- 4. 神煞 ---------- */ function computeShensha(P, dayGan, dayYY, dayWX, sex) { const branches = P.map(p => p.zhi); const allZhi = branches; const dayZhi = P[2].zhi, yearZhi = P[0].zhi; const res = []; // 天乙贵人(以日干查) const tianyi = { 甲: ['丑', '未'], 戊: ['丑', '未'], 庚: ['丑', '未'], 乙: ['子', '申'], 己: ['子', '申'], 丙: ['亥', '酉'], 丁: ['亥', '酉'], 壬: ['卯', '巳'], 癸: ['卯', '巳'], 辛: ['午', '寅'] }; const tyList = tianyi[dayGan] || []; tyList.forEach(z => { if (allZhi.includes(z)) res.push({ name: '天乙贵人', where: '命带' + z, good: true, desc: '一生逢凶化吉、遇难有贵人相助,人缘与运气的"保险绳"。' }); }); // 桃花(咸池)——以年支/日支查 const taohua = { 申: '酉', 子: '酉', 辰: '酉', 寅: '卯', 午: '卯', 戌: '卯', 巳: '午', 酉: '午', 丑: '午', 亥: '子', 卯: '子', 未: '子' }; const th1 = taohua[yearZhi], th2 = taohua[dayZhi]; const thSet = new Set([th1, th2].filter(Boolean)); thSet.forEach(z => { if (allZhi.includes(z)) res.push({ name: '桃花', where: '命带' + z, good: true, desc: '异性缘好、人缘佳、有魅力;用在正处是人际加分,需把握分寸。' }); }); // 驿马——年支/日支查 const yima = { 申: '寅', 子: '寅', 辰: '寅', 寅: '申', 午: '申', 戌: '申', 巳: '亥', 酉: '亥', 丑: '亥', 亥: '巳', 卯: '巳', 未: '巳' }; const ymSet = new Set([yima[yearZhi], yima[dayZhi]].filter(Boolean)); ymSet.forEach(z => { if (allZhi.includes(z)) res.push({ name: '驿马', where: '命带' + z, good: null, desc: '主奔波、出行、变动多,适合外出发展、出差、异地求财,静不下来。' }); }); // 华盖——年支/日支查 const huagai = { 申: '辰', 子: '辰', 辰: '辰', 寅: '戌', 午: '戌', 戌: '戌', 巳: '丑', 酉: '丑', 丑: '丑', 亥: '未', 卯: '未', 未: '未' }; const hgSet = new Set([huagai[yearZhi], huagai[dayZhi]].filter(Boolean)); hgSet.forEach(z => { if (allZhi.includes(z)) res.push({ name: '华盖', where: '命带' + z, good: null, desc: '聪明、有艺术/玄学/宗教缘,喜独处、有精神追求,但也易孤高。' }); }); // 文昌——日干查 const wenchang = { 甲: '巳', 乙: '午', 丙: '申', 丁: '酉', 戊: '申', 己: '酉', 庚: '亥', 辛: '子', 壬: '寅', 癸: '卯' }; const wc = wenchang[dayGan]; if (wc && allZhi.includes(wc)) res.push({ name: '文昌', where: '命带' + wc, good: true, desc: '聪明好学、利考试文书,读书、考试、写作较有优势。' }); // 羊刃——日干查 const yangren = { 甲: '卯', 乙: '寅', 丙: '午', 丁: '巳', 戊: '午', 己: '巳', 庚: '酉', 辛: '申', 壬: '子', 癸: '亥' }; const yr = yangren[dayGan]; if (yr && allZhi.includes(yr)) res.push({ name: '羊刃', where: '命带' + yr, good: null, desc: '性格刚强、有冲劲、执行力和魄力强;也易冲动,宜修心、忌赌气。' }); // 红鸾/天喜(以年支查) const hongluan = { 子: '卯', 丑: '寅', 寅: '丑', 卯: '子', 辰: '亥', 巳: '戌', 午: '酉', 未: '申', 申: '未', 酉: '午', 戌: '巳', 亥: '辰' }; const hl = hongluan[yearZhi]; if (hl && allZhi.includes(hl)) res.push({ name: '红鸾', where: '命带' + hl, good: true, desc: '主婚恋喜庆、人缘好,感情运佳、易有喜事。' }); // 天德/月德(简化略)——用词条保留 // 空亡(以日柱旬空) const kong = computeKongwang(P[2].gan, P[2].zhi); if (kong) res.push({ name: '空亡', where: '日柱' + P[2].gan + P[2].zhi + '旬空' + kong, good: null, desc: '相关宫位易有空虚、想多、落实难之象;逢冲则解。' }); // 去重 const seen = new Set(); const out = []; res.forEach(r => { const k = r.name + r.where; if (!seen.has(k)) { seen.add(k); out.push(r); } }); return out; } function computeKongwang(dayGan, dayZhi) { // 六十甲子旬空:根据日柱所在旬查空亡两字 const ganIdx = GAN.indexOf(dayGan), zhiIdx = ZHI.indexOf(dayZhi); // 旬首:找甲x的zhi偏移 const xunHeadZhi = ((zhiIdx - ganIdx) % 12 + 12) % 12; const kong1 = ZHI[(xunHeadZhi + 10) % 12], kong2 = ZHI[(xunHeadZhi + 11) % 12]; return kong1 + kong2; } /* ---------- 5. 精确起运 & 大运 ---------- */ function computeQiyun(birth, P, sex) { const yearGan = P[0].gan, yearYY = GAN_YY[yearGan]; const isMale = String(sex) === '1' || sex === '男'; const forward = (yearYY === 1 && isMale) || (yearYY === -1 && !isMale); const bornJD = toJD(birth.year, birth.month, birth.day, birth.hour || 0, birth.minute || 0); // 找出生前后相邻的节 let ev = []; for (const yr of [birth.year - 1, birth.year, birth.year + 1]) { for (let i = 0; i < 12; i++) { const t = jieTime(yr, JIE_LONG[i]); if (t > bornJD - 50 && t < bornJD + 50) ev.push({ name: JIE_NAME[i], jd: t }); } } ev.sort((a, b) => a.jd - b.jd); ev = ev.filter((e, i) => i === 0 || Math.abs(e.jd - ev[i - 1].jd) > 1); const prev = ev.filter(e => e.jd <= bornJD).pop(); const next = ev.find(e => e.jd > bornJD); const refJie = forward ? next : prev; let days = refJie ? Math.abs((forward ? refJie.jd - bornJD : bornJD - refJie.jd)) : 0; const yearsF = days / 3; const yy = Math.floor(yearsF); const monthsF = (yearsF - yy) * 12; const mm = Math.floor(monthsF); const daysExtra = Math.round((monthsF - mm) * 30); // 大运序列:从月柱起,顺/逆排 const monthGan = P[1].gan, monthZhi = P[1].zhi; let gi = GAN.indexOf(monthGan), zi = ZHI.indexOf(monthZhi); const list = []; let startAge = yy + mm / 12; for (let i = 1; i <= 8; i++) { gi = (gi + (forward ? 1 : -1) + 10) % 10; zi = (zi + (forward ? 1 : -1) + 12) % 12; const ageStart = startAge + (i - 1) * 10; list.push({ gz: GAN[gi] + ZHI[zi], ageStart: +ageStart.toFixed(1), yearStart: birth.year + Math.floor(ageStart), tenGod: relationToDay(GAN_WX[P[2].gan], GAN_YY[P[2].gan], GAN_WX[GAN[gi]], GAN_YY[GAN[gi]]) }); } return { forward, refJieName: refJie ? refJie.name : '', days: +days.toFixed(2), startAge: +startAge.toFixed(2), startText: `${yy}岁${mm}个月` + (daysExtra ? `${daysExtra}天` : ''), ganZhi: `${yy}年${mm}个月` , list, note: `${yearYY === 1 ? '阳' : '阴'}年${isMale ? '男' : '女'},大运${forward ? '顺' : '逆'}排;出生距${refJie ? (forward ? '下一节' : '上一节') + '"' + refJie.name + '"' : '节气'}约 ${days.toFixed(1)} 天,按"3天折1岁"得 ${yy}岁${mm}个月起运。` }; } /* ---------- 6. 大白话解读 ---------- */ function buildReadings(dayWX, dayGan, lv, yong, ji, ss, geju, rels, shensha, qiyun) { const r = {}; const strong = lv >= 2; // 性格(大白话) const xing = { 木: '你是"木"命,性格像树——有向上生长的劲儿,心软、讲道理、爱帮人,但有时认死理、爱面子。', 火: '你是"火"命,性格像火——热情、反应快、爱表现、有感染力,但性子急、容易三分钟热度。', 土: '你是"土"命,性格像大地——踏实、靠谱、能包容、守承诺,但有时太保守、想得多动得少。', 金: '你是"金"命,性格像金属——干脆、讲原则、讲义气、有执行力,但有时太硬、说话直容易得罪人。', 水: '你是"水"命,性格像水——聪明、机灵、会变通、点子多,但有时想法太多、容易犹豫、坐不住。' }; let xg = xing[dayWX]; xg += strong ? ' 整体能量偏强:你主见强、扛得住事,但也容易固执、听不进劝,学会放低姿态会走得更远。' : ' 整体能量偏弱:你心思细、较敏感,容易累、容易内耗,多给自己一点底气和果断会更好。'; if (ss['比肩'] || ss['劫财']) xg += ' 朋友缘旺、爱热闹、有竞争心。'; if (ss['正印'] || ss['偏印']) xg += ' 爱学习、重精神、想得多。'; if (ss['食神'] || ss['伤官']) xg += ' 有才艺、爱表达、点子多。'; r['性格'] = xg; // 事业(大白话) let sy = ''; if (ss['正官'] || ss['七杀']) sy += '你适合"上班、进组织、走平台"的路子,管理、公职、技术骨干这类有规矩、有台阶的岗位能发挥;'; else sy += '你不太喜欢被管,适合自主、自由度高、能自己说了算的活儿,比如做生意、自由职业、专业技能;'; if (ss['正财'] || ss['偏财']) sy += '你对钱有感觉、会算账,做跟经营、买卖、销售相关的更容易来钱;'; if (ss['食神'] || ss['伤官']) sy += '靠才华、创意、嘴皮子或手艺吃饭很吃香。'; sy += ` 想加分,就多做${yong.join('、')}相关的事(比如行业、方向、颜色),少陷在${ji.join('、')}里。`; r['事业'] = sy; // 感情(大白话) let gq = ''; const spouseStar = ss['正财'] || ss['偏财'] || ss['正官'] || ss['七杀']; if (spouseStar) gq += '你命里"另一半"的信息明显,异性缘不差,只要愿意经营,婚姻感情能顺;'; else gq += '你命里"另一半"的星不明显,感情上别太被动,主动一点、多让人介绍更容易成;'; if (rels.some(x => x.includes('相冲'))) gq += ' 但地支有"冲",感情容易有起伏或聚少离多,遇事多沟通、别赌气,很重要。'; else gq += ' 地支比较和顺,感情整体平稳。'; r['感情'] = gq; // 健康(大白话) const part = { 木: '肝、胆、筋、眼睛', 火: '心脏、血压、睡眠', 土: '脾胃、消化', 金: '肺、呼吸道、皮肤', 水: '肾、泌尿、腰、耳朵' }; let jk = `平时要多留意${ji.map(k => part[k]).join('、')}这些方面;`; jk += strong ? '你能量足但容易"硬扛",注意别熬夜、别上火、学会泄压。' : '你底子偏虚,别过度劳累、注意保暖、规律吃饭,养比拼更重要。'; r['健康'] = jk; // 神煞总结 if (shensha && shensha.length) { r['命带神煞'] = shensha.map(s => `${s.name}(${s.desc})`).join(' '); } return r; } /* ---------- 7. 导出文本(复制/下载) ---------- */ function toText(res) { if (!res) return '无命盘数据'; const L = []; const P = res.pillars, POSN = ['年', '月', '日', '时']; L.push('===== 命盘智能分析 ====='); if (res.bz.name) L.push('姓名:' + res.bz.name); L.push('四柱:' + P.map((p, i) => POSN[i] + p.gan + p.zhi).join(' ')); L.push('日主:' + res.dayGan + '(' + res.dayWX + ') 强弱:' + res.strength + '(帮扶占比 ' + res.ratio + '%)'); L.push(''); L.push('【五行力量】'); L.push(Object.keys(res.wx).map(k => k + ' ' + res.pct[k] + '%').join(' ')); L.push(''); L.push('【喜用神】喜:' + res.yongShen.join('、') + ' 忌:' + res.jiShen.join('、')); L.push(res.reason); L.push(''); L.push('【十神】' + Object.entries(res.shiShenCount).map(([k, v]) => k + '×' + v).join(' ')); L.push('【格局】' + res.geju); if (res.rels.length) L.push('【地支关系】' + res.rels.join(';')); if (res.shensha && res.shensha.length) { L.push(''); L.push('【命带神煞】'); res.shensha.forEach(s => L.push('· ' + s.name + '(' + s.where + '):' + s.desc)); } if (res.qiyun) { L.push(''); L.push('【起运】' + res.qiyun.startText + '起运 ' + (res.qiyun.forward ? '顺排' : '逆排')); L.push(res.qiyun.note); L.push('【大运】' + res.qiyun.list.map((d, i) => `${i + 1}.${d.gz}(${d.ageStart}岁)`).join(' ')); } L.push(''); L.push('【分项解读】'); ['性格', '事业', '感情', '健康', '命带神煞'].forEach(k => { if (res.readings[k] && k !== '命带神煞') L.push('◆ ' + k + ':' + res.readings[k]); }); L.push(''); L.push('(纯本地规则生成,仅供文化娱乐与自我参考,不构成医疗/投资/婚恋等决策依据。)'); return L.join('\n'); } global.__BaziCore = { GAN, ZHI, GAN_WX, GAN_YY, ZHI_WX, ZHI_YY, ZHI_CANG, relationToDay, getBazi, parseFromURL, parseFromDOM, analyze, computeShensha, computeQiyun, toText, POS, JIE_NAME }; })(typeof window !== 'undefined' ? window : this); /* ============================================================================ * 命盘智能分析 · UI 层 bazi-ui.js * 依赖 window.__BaziCore。浮动按钮 + Shadow DOM 面板 + 复制/导出。 * ==========================================================================*/ (function (global) { 'use strict'; const Core = global.__BaziCore; if (!Core) { console.warn('[命盘分析] core 未加载'); return; } const STYLE = ` :host{all:initial} *{box-sizing:border-box;font-family:-apple-system,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif} .fab{position:fixed;right:22px;bottom:90px;width:56px;height:56px;border-radius:50%; background:linear-gradient(135deg,#6b3fa0,#9b59b6);color:#fff;border:none;cursor:pointer; box-shadow:0 6px 18px rgba(107,63,160,.45);font-size:24px;z-index:2147483000; display:flex;align-items:center;justify-content:center;transition:transform .2s} .fab:hover{transform:scale(1.08)} .panel{position:fixed;right:22px;bottom:160px;width:440px;max-width:94vw;max-height:80vh;overflow-y:auto; background:#fff;border-radius:14px;box-shadow:0 14px 45px rgba(0,0,0,.28);z-index:2147483001; display:none;flex-direction:column;color:#222;font-size:14px;line-height:1.7} .panel.show{display:flex} .hd{position:sticky;top:0;background:linear-gradient(135deg,#6b3fa0,#9b59b6);color:#fff; padding:14px 16px;border-radius:14px 14px 0 0;display:flex;justify-content:space-between;align-items:center;z-index:2} .hd h2{margin:0;font-size:16px;font-weight:600} .hd .close{cursor:pointer;font-size:22px;line-height:1;opacity:.85} .hd .close:hover{opacity:1} .bd{padding:14px 16px 22px} .sec{margin-bottom:16px;border-bottom:1px dashed #eee;padding-bottom:12px} .sec:last-child{border:none} .sec h3{margin:0 0 8px;font-size:14px;color:#6b3fa0;display:flex;align-items:center;gap:6px} .sec h3::before{content:"";width:4px;height:14px;background:#9b59b6;border-radius:2px} .pillars{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;text-align:center} .pillar{background:#f7f4fb;border-radius:8px;padding:6px 0} .pillar .pos{font-size:11px;color:#999} .pillar .gz{font-size:20px;font-weight:700;color:#4a2c73;letter-spacing:1px} .pillar .ss{font-size:11px;color:#8a6fb0} .bar{margin:6px 0} .bar-label{display:flex;justify-content:space-between;font-size:12px;color:#555;margin-bottom:2px} .bar-track{height:9px;background:#eee;border-radius:5px;overflow:hidden} .bar-fill{height:100%;border-radius:5px} .tag{display:inline-block;padding:2px 8px;border-radius:10px;font-size:12px;margin:2px 4px 2px 0} .tag-y{background:#e8f5e9;color:#2e7d32} .tag-j{background:#ffebee;color:#c62828} .tag-n{background:#eef3fb;color:#345} .kv{font-size:13px;color:#333;margin:3px 0} .kv b{color:#6b3fa0} .num{color:#6b3fa0;font-weight:600} .note{font-size:11px;color:#aaa;margin-top:10px;line-height:1.5} .src{font-size:11px;color:#999;margin-left:8px;font-weight:400} .empty{padding:20px;text-align:center;color:#888} .ss-item{font-size:12px;background:#faf7ff;border-left:3px solid #b39ddb;padding:4px 8px;margin:4px 0;border-radius:0 6px 6px 0} .ss-item b{color:#6b3fa0} .dayun{display:flex;flex-wrap:wrap;gap:6px} .dayun .d{background:#f7f4fb;border-radius:6px;padding:3px 8px;font-size:12px;color:#4a2c73} .toolbar{display:flex;gap:8px;margin-top:6px;position:sticky;bottom:0;background:#fff;padding:8px 0 2px} .btn{flex:1;padding:8px 0;border-radius:8px;border:1px solid #9b59b6;background:#fff;color:#6b3fa0; cursor:pointer;font-size:13px;font-weight:600;transition:.15s} .btn:hover{background:#f3ecfc} .btn.primary{background:linear-gradient(135deg,#6b3fa0,#9b59b6);color:#fff;border:none} .btn.primary:hover{opacity:.9} .toast{position:fixed;right:30px;bottom:150px;background:#333;color:#fff;padding:8px 14px;border-radius:8px; font-size:13px;z-index:2147483002;opacity:0;transition:opacity .3s;pointer-events:none} .toast.show{opacity:.95} `; function el(tag, cls, html) { const e = document.createElement(tag); if (cls) e.className = cls; if (html != null) e.innerHTML = html; return e; } function wxColor(wx) { return { 木: '#2e7d32', 火: '#e53935', 土: '#8d6e63', 金: '#f9a825', 水: '#1e88e5' }[wx] || '#888'; } function esc(s) { return String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c])); } const POSN = ['年', '月', '日', '时']; function buildPanelContent(res) { const wrap = el('div', 'bd'); if (!res) { wrap.innerHTML = '