// This script prevents Google from indexing Table of Contents fragment URLs while keeping TOC navigation functional
document.addEventListener("DOMContentLoaded", function() {
// Check if Googlebot is crawling
let isGooglebot = /Googlebot/i.test(navigator.userAgent);
if (isGooglebot) {
// If Googlebot, remove the fragment from TOC links
document.querySelectorAll("a[href*='#ruffruff-table-of-contents-item']").forEach(function(link) {
let cleanUrl = window.location.href.split("#")[0]; // Get main URL without fragment
link.href = cleanUrl; // Set TOC links to main page URL for Googlebot
});
}
});