Detect when Devtools is open for Chrome platform (extensions/apps)
- Download and drag and drop example folder into
chrome://extensions/
page - Then inspect the
background page
Download devtools-detect.js
\
...
devtools-detect.js
manifest.json
background.js
devtools.html
devtools.js
...
{
...
"background": {
"scripts": [
"/devtools-detect.js",
"/background.js"
]
},
"devtools_page": "devtools.html",
...
}
//init
devtools_detect.background();
//listener
devtools_detect.addListener(function() {
console.log('devtools is open !');
});
<!DOCTYPE html>
<html>
<head>
<script src="/devtools-detect.js"></script>
<script src="/devtools.js"></script>
</head>
<body>
</body>
</html>
//init
devtools_detect.devtools_page();
.addListener
: add listener for Devtools open event.
//listener
devtools_detect.addListener(function() {
console.log('devtools is open !');
});