I used this script to remove the custom menus:
#target "indesign"
try {
var menuName = "example menu"; // Replace with the actual name of your custom menu
var foundMenu = null;
function findMenu(menus) {
for (var i = 0; i < menus.length; i++) {
$.writeln("Checking menu: " + menus[i].name);
if (menus[i].name === menuName) {
return menus[i];
}
// Check if there are submenus and search them too
if (menus[i].submenus.length > 0) {
var submenu = findMenu(menus[i].submenus);
if (submenu) {
return submenu;
}
}
}
return null;
}
foundMenu = findMenu(app.menus);
if (foundMenu && foundMenu.isValid) {
foundMenu.remove();
alert("Custom menu '" + menuName + "' has been removed.");
} else {
alert("Custom menu '" + menuName + "' was not found.");
}
} catch (e) {
alert("Error: " + e.message);
}
This removed the menus from the menu bar, but if you go Edit > Menus, the menu items are still listed under the Application Menus.