If the phone is rooted, you can use Advanced Charging Controller to cycle it between min/max values. That would only prolong it, of course.
also mentioned at https://news.ycombinator.com/item?id=27576120#27578301
and related https://news.ycombinator.com/item?id=31325191#31325561 (laptop)
Also, an alternative to termux, https://github.com/CypherpunkArmory/UserLAnd found https://news.ycombinator.com/item?id=30119029