document.addEventListener("DOMContentLoaded", function() {
// Define the menu items matching drivetheory.co
var menuItems = [
{ text: "HOME", href: "https://www.drivetheory.co/" },
{ text: "STORAGE", href: "https://www.drivetheory.co/#carstorage" },
{ text: "SOCIAL", href: "https://www.drivetheory.co/#socialclub" },
{ text: "STORE", href: "https://store.drivetheory.co/" },
{ text: "PROJECT CARS", href: "https://www.drivetheory.co/project-cars/" },
{ text: "BLOG", href: "https://www.drivetheory.co/blog/" },
{ text: "CONTACT", href: "https://www.drivetheory.co/#contact" }
];
function replaceMenu() {
var menuList = document.querySelector(".WaGadgetMenuHorizontal .menuInner ul.firstLevel");
if (!menuList) return false;
// Clear the existing menu items
menuList.innerHTML = "";
// Create new menu items
menuItems.forEach(function(item) {
var li = document.createElement("li");
li.className = "firstLevelItem";
var div = document.createElement("div");
div.className = "item";
var a = document.createElement("a");
a.href = item.href;
a.textContent = item.text;
a.target = "_self";
div.appendChild(a);
li.appendChild(div);
menuList.appendChild(li);
});
return true;
}
// Try immediately, then retry with intervals for dynamic content
if (!replaceMenu()) {
var attempts = 0;
var interval = setInterval(function() {
attempts++;
if (replaceMenu() || attempts > 20) {
clearInterval(interval);
}
}, 250);
}
});