I have cleaned my browser cache to test a couple of things and found out that the script does not pick up the favourite names unless you have opened the favourite popup at least once.
i.e. if i clear the cache the localStorage is not there so i get "Favourite 1", "Favourite 2", etc.
The problem is that to update the localStorage i need to run if ( isFavouritePopupPage() ), which will not happen as long as i am using the script. In other words, i can read the code and force the correct URL to get the favourites, but most users won't do it.
Maybe it would be better to do it in the following fashion:
1. if EHGQF-fav cannot be found in localStorage
1.1. fire a request to gallerypopups.php?addfav
1.2. update localStorage with favourite names
2. else do nothing
3. Updage #gdf with favourite names from localStorage
I'd take this part (inside updateCurrentFav):
CODE
} else {
// Fetch the Labels of the 10 Fav items
var favLabels = [];
for (i=0; i<10; i++) {
var label = localStorage.getItem(`EHGQF-fav${i}`);
if ( !label ) label = `Favorites ${i}`;
favLabels.push(label);
}
And transform into a procedure of its own. Then put a big if in there, that, if a certain fav label cannot be found fire a request to gallerypopups.php and scrap the labels from there.