How can we overwrite navigator.getBattery()?
问题 We are writing a chrome extension that returns a random battery level when the battery level is checked by a site running client-side code for fingerprinting reasons. Sample code that can be used by a site can be seen below. navigator.getBattery().then(function(battery) { console.log(battery.level); }); We are unable to find documentation regarding how the navigator.getBattery() method can be overwritten to accomplish the goal. The incomplete content-script.js can be seen below. var