As you got it working, it's good.
Anyway it's also possible to use similar script in web-browser console (F12 key), so here is my script, tested in Firefox. Edit the search link to filter activities…
You could delete all your activities, insure the default privacy setting in you account settings is what you want it to be, then upload all your activities again.
If it helps anyone, I've written up this post with a bit more of a step by step approach to updating privacy settings, all based on the hard work already done here. I'm not a whizz at this stuff so needed to step through it and hope it can help someone else.