Plug your charger to any Homekit-compatible "smart plug," and create a shortcut that turns the the plug on when the battery reaches 45%, and off when it reaches 55%.
This will of course require a Homekit hub.
This will of course require a Homekit hub.
Unfortunately it wouldn't work for my particular usage, which was keeping it plugged into an old but expensive smart speaker as a music player via its lightning port. A smart plug would turn off the speaker along with the phone... But I appreciate the suggestion, as complicated as it is!