I'm not sure I'm doing a good job of explaining myself. This GIF comes from the same site where I found that code, but it's over five years old.
If the script registers the name "Featured Prdouct", it looks for any group with same name and toggles off the visibility. I don't know if running the script a second time would switch them back on.

the script you posted does exactly what you need, except it doesn't toggle all groups visibility on/off (meaning all on or all off). It toggles visibility per item. If an item is on, it will be turned off, but if some other item is off it will be turned on.
is it not working on your end?
try this version, it's the same script you posted, I just added a Window to enter the group name so you don't have to edit the script each time.
Also, yes, if you start with all on, running the script will turn them all off. Running the script a second time will turn them all on.
Group Name is Case Sensitive
// jshint -W118
// globals app
// jshint ignore:start
#target illustrator
// #targetengine main
// jshint ignore:end
function loop(flag, layers) {
var groups, groupsCount;
var subLayers, subLayersCount;
var i1, i1l;
var i2, i2l;
// Loop over layers:
for (i1 = 0, i1l = layers.length; i1 < i1l; i1++) {
$.writeln('Layer: ', layers[i1].name);
// Get layer groups:
groups = layers[i1].groupItems;
groupsCount = groups.length;
// If there are nested groups:
if (groupsCount) {
for (i2 = 0, i2l = groups.length; i2 < i2l; i2++) {
$.writeln('Group: ', groups[i2].name);
// Does group match flag?
if (groups[i2].name.toLowerCase() == flag) {
// Flag matched, so toggle hidden attribute:
groups[i2].hidden = (!groups[i2].hidden);
}
}
}
// Get layer layers:
subLayers = layers[i1].layers;
subLayersCount = layers.length;
// If there are nested layers:
if (subLayersCount) {
// Call self and recurse:
loop(flag, subLayers);
}
}
}
if (app.documents.length > 0) {
// This script assumes you want to toggle visibility of “groups”
// with a name that matches first argument passed below.
loop(
Window.prompt("Enter Name of Group to Toggle Visibility", "width", "Toggle Group Visibility"), // Group name used to toggle visibility.
app.activeDocument.layers
);
}