Note that the Battery Status API is no longer available due to privacy reasons where it could be used by remote trackers for user fingerprinting.
The Battery Status API is an Application Programming Interface for the client's battery status. It provides information on:
'chargingchange'
event and battery.charging
;'levelchange'
event and battery.level
;'chargingtimechange'
event and battery.chargingTime
;'dischargingtimechange'
event and battery.dischargingTime
.MDN Docs: https://developer.mozilla.org/en/docs/Web/API/Battery_status_API