document.addEventListener('DOMContentLoaded', function() {
let checkNotionLoaded = setInterval(() => {
let notionTopbar = document.querySelector('.notion-topbar');
if (notionTopbar) {
clearInterval(checkNotionLoaded); // 停止检查
// **创建自定义导航栏**
let customNav = document.createElement('div');
customNav.className = 'custom-content';
customNav.innerHTML = `
Home
About
Investors
Contacts
`;
// **插入到 Notion 顶部导航栏**
let existingLeft = notionTopbar.firstElementChild;
if (existingLeft) {
existingLeft.insertAdjacentElement('beforebegin', customNav);
} else {
notionTopbar.appendChild(customNav);
}
}
}, 500); // 每 500ms 轮询一次,直到 Notion 顶部栏加载
});
// **插入 CSS 样式**
const style = document.createElement('style');
style.innerHTML = `
.notion-topbar {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
width: 100%;
height: 44px;
background: #663399; /* 紫色背景 */
padding: 0 20px;
}
.custom-content {
display: flex;
align-items: center;
height: 100%;
}
.custom-content a {
color: white;
text-decoration: none;
margin: 0 10px;
font-size: 14px;
}
.custom-content a:hover {
text-decoration: underline;
}
`;
document.head.appendChild(style);