document.addEventListener("DOMContentLoaded", function () {
const excludedPages = [
"entry/대학병원-치과-임플란트-시술-특징-예약-방법-절차-유의사항"
];
const currentURL = window.location.href;
for (const keyword of excludedPages) {
if (currentURL.includes(keyword)) return;
}
const article = document.querySelector("article") || document.body;
const headers = article.querySelectorAll("h2, h3");
const firstH2 = article.querySelector("h2, h3");
if (!headers.length || !firstH2) return;
const tocContainer = document.createElement("div");
tocContainer.id = "auto-toc";
tocContainer.style = `
background: #f9f9f9;
border-left: 6px solid #ffb703;
border-radius: 6px;
padding: 20px;
margin: 20px 0;
font-size: 15px;
line-height: 1.6;
`;
let tocHTML = `
🗂 목차 보기
`;
headers.forEach((header, i) => {
const text = header.innerText.trim();
const excluded = ["관련 글", "태그", "댓글", "티스토리툴바"];
if (!text || excluded.includes(text)) return;
const id = "toc-item-" + i;
header.id = id;
tocHTML += `- ${text}
`;
});
tocHTML += "
";
tocContainer.innerHTML = tocHTML;
firstH2.parentNode.insertBefore(tocContainer, firstH2);
});