Widget:Testlog
刷
历
编
跳到导航
跳到搜索
<script>
(() => {
console.log('[MathJax] 开始监控 MathJax 状态');
// 1. 仅配置日志相关的部分
window.MathJax = {
startup: {
pageReady: () => {
console.log('[MathJax] 页面准备就绪,开始初始化');
return MathJax.startup.defaultPageReady();
}
},
options: {
renderActions: {
addMenu: [],
checkLoading: [],
typeset: []
}
}
};
// 2. 监听 MathJax 全局事件
const originalOnLoad = window.onload;
window.onload = function() {
console.log('[MathJax] 窗口加载完成');
if (originalOnLoad) originalOnLoad.apply(this, arguments);
};
// 3. 检查是否已存在 MathJax
if (window.MathJax && window.MathJax.version) {
console.log('[MathJax] MathJax 已预先加载,版本:', window.MathJax.version);
} else {
console.log('[MathJax] 等待 MathJax 加载');
}
// 4. 设置 MutationObserver 监控 MathJax 脚本加载
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.tagName === 'SCRIPT' &&
node.src &&
node.src.includes('mathjax')) {
console.log('[MathJax] 检测到 MathJax 脚本标签:', node.src);
// 监听脚本加载事件
node.addEventListener('load', () => {
console.log('[MathJax] MathJax 脚本加载成功');
if (window.MathJax && window.MathJax.startup) {
console.log('[MathJax] MathJax 实例创建成功');
}
});
node.addEventListener('error', () => {
console.error('[MathJax] MathJax 脚本加载失败');
});
}
});
});
});
// 开始监控 document.head
observer.observe(document.head, { childList: true });
console.log('[MathJax] 监控器已启动');
})();
</script>

沪公网安备 31011002002714 号