// Get the battery API navigator.getBattery().then(function(battery) { console.log( "Battery will drain in ", battery.dischargingTime, " seconds" ); });