I've had an HTC One M8 for a little over a year now and started having overheating problems at some point in July. I followed all of the advice on both this forum and others and found that nothing worked. At the time I didn't have any games and the only apps I had on the phone were productivity apps (Word, Excel, PowerPoint, One Note, Reader, Adobe PDF, etc.). After unsuccessfully solving the problem through doing a factory reset I went to Verizon and they sent me a new phone. The same problem reappeared the day I took the new phone out of the box. I took it to Verizon yet again and, hot enough to cook an egg on, they took it back and swapped it out yet again. The third phone had the same damn problem, too.
I don't recall why, but at some point I decided to turn off my cellular data and found, much to my surprise, that the overheating stopped completely. These days I keep it off almost all the time and only turn it on if I'm in an area without WiFi and need access to the internet. Another unintended but positive side effect of turning off the cellular data is that the battery life has lengthened considerably. In the past on days where there was no overheating the battery would barely carry me to the end of the day (and that was only doing some mild internet browsing on news sites and some limited text messaging). These days I can get two full days of use even with a decent level of usage that includes internet browsing, text messaging, playing Halo: Spartan Assault for ten to fifteen minutes per day, playing Tetris Blitz for roughly the same amount of time, and listening to music (stored on the phone) or the FM radio at volume of 11 to 16 for an hour or so.
Turning off the cellular data does not hinder your ability to send or receive text messages, though Cortana and speech-to-text will not work without cellular data enabled. GPS will still provide you with your location and you can still follow directions to a destination, but you generally cannot enter new destinations that are not already stored in your phone. If I need to go to a new place I usually enable cellular data, locate the place I want to go, get directions, and then turn off the cellular data. My phone currently runs Windows Phone 8.1 Update 2 which permits the pinning of individual settings to the home screen. I went to the settings menu, tapped and held "Cellular + SIM" and pinned it to the start. If I absolutely need cellular data it's only two taps away if you're already at the home screen, three taps if you're not. See the screenshots I attached to this post. My phone's default language is Chinese, so apologies there, but the settings are in the same order and the functions are the same regardless of language.
I have no clue if this "fix" will work for other people, but this overheating issue seems to be relatively common and the fact that HTC has not yet fixed it is absolutely ridiculous.