I switched off the https redirect but that resulted in the same behaviour. With Dave's comments in mind, I then studied the event triggers again and discovered that there was indeed still a timing issue resulting in a completely silent failure of the script. It was running, it was just finding nothing!
Beginner's incompetence I guess. At least now I realise just how evil this Javascript monster can be! 😊
Thank you very much for your comments and help.
Regards
Richard