Plug [Q] [PLEASE HELP] HTC One M7 not charging when on.

Device: HTC One (M7) Stock ROM

A few days ago, my never rooted, stock firmware, no unlocked boot loader, no custom ROM, never dropped HTC One (M7)'s battery died. Plugging in the charger had no effect, absolutely NOTHING. Tried 6 different cables and 9 different locations to charge it, nothing. Waited a while, dying in desperation. Then after so much of panic, I plugged it again, and randomly it started charging. But the charging had a loop - showed a bright orange LED with the power symbol on a battery for about 5 seconds, then a dim orange LED with the green battery charging, and a number, for about 10 seconds. The loop kept repeating. Eventually I could turn it on till the (incredibly low capacity) battery could live. So I did about 10 resets to it, and the situation would not improve.

Since my phone just decided to do this to me just before a long journey of mine, I was quite upset, and eventually infuriated to the limits. I decided to take it along and try different things to it - tried, tried, cleaned the ports, searched the net, nothing.

One fine day it decided to break the loop - now it charged, but only when off.

And today again its started the loop.

And here I am, begging for some help. I'm starting to hate this device now. Please help me..

P.S. : I played a lot of Clash of Clans on the phone - it heated up a lot. Hope the info helps (Possible corrupted overheating charge instructions of the phone,etc.)