sindresorhus / devtools-detect Goto Github PK
View Code? Open in Web Editor NEWDetect if DevTools is open and its orientation
Home Page: https://sindresorhus.com/devtools-detect
License: MIT License
Detect if DevTools is open and its orientation
Home Page: https://sindresorhus.com/devtools-detect
License: MIT License
After installing it using NPM, I could not do
import devtools from "devtools-detect";
or
var devtools = require('devtools-detect');
I had to install using Bower and then copy the devtools-detect.js
file to /libs
directory and then using browserify I could do:
import devtools from './libs/devtools-detect.js';
And then it worked.
Am I doing something wrong?
i check this script in windows 7 chrome browser but this could not detect
if dev tools is close still getting developer console is open
please check and revert me as soon as posible
Does not determine the state of devtools when mobile view is enabled.
We at VersionEye are working hard to keep up the quality of the bower's registry.
We just finished our initial analysis of the quality of the Bower.io registry:
7530 - registered packages, 224 of them doesnt exists anymore;
We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).
Sadly, your library sindresorhus/devtools-detect
is one of them.
Can you spare 15 minutes to help us to make Bower better?
Just add a new file bower.json
and change attributes.
{
"name": "sindresorhus/devtools-detect",
"version": "1.0.0",
"main": "path/to/main.css",
"description": "please add it",
"license": "Eclipse",
"ignore": [
".jshintrc",
"**/*.txt"
],
"dependencies": {
"<dependency_name>": "<semantic_version>",
"<dependency_name>": "<Local_folder>",
"<dependency_name>": "<package>"
},
"devDependencies": {
"<test-framework-name>": "<version>"
}
}
Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.
NB! Please validate your bower.json with jsonlint before commiting your updates.
Thank you!
Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!
It's not working correctly when we use theToggle Device Toolbar or [Ctrl + Shift + M] on devtools
I usually have devtools open in another window on another monitor, this script doesn't detect that scenario. The devtools window has to be attached to the browser.
Tested in Chrome build 32.0.1700.102
If we zoom the screen it will fail . Do we have any solution for this
http://ariya.ofilabs.com/2011/08/hall-of-api-shame-boolean-trap.html
feels bad.
pass an object instead!
Firefox and safari can be used normally, only in Google Chrome does not work
Overall, it works well in the same page.
However, if the code should run on the new window, then it won't work.
And I found that if the devtool opens as the new window, the code can't feagure out whether it opened or closed.
Upon enabling developer tools, a JS error appears on the test page:
SCRIPT445: Object doesn't support this action
File: devtools-detect.js, Line: 13, Column: 3
Devtools-detect detects DevTools use in Mobile Safari or Chrome on iPhone 11.
But this is misdetect.Is there any solution?
I there's a polyfill or an idea to fix when DevTools is undocked, it should be added to this thread.
Bookmarklets are not detected, and can easily inject JavaScript.
If you just detach the dev tools from the page, it will not work anymore.
I'm the PM on Edge DevTools, and I was wondering if we could help this extension, by setting a property on the global object when the DevTools are opened?
The current approach seems rather hacky, and I imagine it would be easy to get implemented in most engines
interface DevTools {
attribute Boolean isOpen;
attribute String dockState;
}
window.devTools.isOpen
window.devTools.dockState // 'left, right, top, bottom, inline'
Hi, can you convert your code in Pure Javascript plz ?
Cause i don t have node and can t install
Thank you
Hello,
I'm having trouble with monitors with 1920x1980 resolution, it detects as if the console was open.
There is a $40.00 open bounty on this issue. Add more on Issuehunt.
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on Issuehunt to raise funds.
How can I hide the fact that I opened dev tools?
Some site I want to check out finds it out and does stuff to prevent me from using it for example block access to the site.
This is really shit. Where can I get an anti dev tools detection?
Create some examples on how it can be useful.
Ideas:
the demo page not works on Opera Version:70.0.3728.178
When I load the page with devtools open I get this result:
import devtoolsDetect from 'devtools-detect';
console.log(devtoolsDetect.isOpen) // false
I think its because the code if delayed by 500ms.
Could we maybe make the first run be run immediately or add an event for when the devtools detection code has actually been run?
RT
<script type="text/javascript">
var el = new Image();
Object.defineProperty(el, 'id', {
get: function() {
alert('active');
}
});
console.log('%cHello', el);
</script>
Returns open true if the demo page is zoomed in (CTRL + mousewheel up) in chrome.
On line 13 new CustomEvent(...)
raises an error in IE11.
"Object doesn't support this action"
Not sure what the work around is... :-/
If the dev tools are in the floating option, it doesn't work.
If you put javascript:window.devtools={open:false};
in the url and press enter, the devtool detection stops working.
Seems to work on the now-basically-Chrome versions.
Hi
Doesnt seem to work in internet explorer is get this error
window.dispatchEvent(new CustomEvent('devtoolschange', {
detail: {
open: state
}
}));
Its says
Object doesnt support this action
Any suggestions?
Thanks
Not work for Edge.
Edge version : 42.17134.1098.0
Error message in console:
SCRIPT5009: SCRIPT5009: 'globalThis' is not defined
It seems that new versions of Firebug doesn't modify 'window' object with 'Firebug', so it's useless to check for 'window.Firebug'. It instead adds new function called 'window.console.exception' which can be used for detection.
The script doesn't take care about Firebug lite
All you have to do is checking window.Firebug
const widthThreshold = window.outerWidth - window.innerWidth * window.devicePixelRatio > threshold
const heightThreshold = window.outerHeight - window.innerHeight * window.devicePixelRatio > threshold
//yes, just add `* window.devicePixelRatio`
Zooming in Google Chrome (using CTRL + or -) seems to make the script think that the console was opened. This does not occur in Firefox.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.