- Return type:
Object
{
bool isOpen, // true if DevTools are open
enum["vertical", "horizontal", null] orientation, // Orientation of the pane. null if isOpen is false
}
Starts listening for DevTools state changes each specified interval. interval
defaults to 500.
Event of type CustomEvent("devtoolschange")
is being pushed on window as a result.
Events start to come after the next change, there's no initialization event. The event contains
detail
field with detectDevTools
call result and source
property, which contains the
constructor.
- Return type:
Constructor
{
Object lastState, // Last return value of detectDevTools()
Function disconnect(), // Stop listening for changes
}
// Start listening for the changes once per second
new DevToolsListener(1000);
// Set event
window.addEventListener('devtoolschange', function (e) {
// Ignore if DevTools are not open
if (!e.detail.isOpen) return;
// Stop listening
e.detail.source.disconnect();
// Output orientation
console.log(e.detail.orientation)
});