1.0.4 • Published 11 months ago

detect-devtools v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Devtool detection based on debugger and webworkers.

Getting started

Install via npm

npm i detect-devtools

Or download detect-devtools.js

Usage

<script type="module">
    import { detectDevtools } from './detect-devtools.js'
    // "change" will be called on every detectDevtools.info.isOpen change and initially
    detectDevtools.addEventListener("change", (e) => {
        console.log("detectDevtools.info.isOpen " + e.detail.isOpen)
        // or use detectDevtools.info.isOpen
    })

    detectDevtools.startDetectDevtools()
    // detectDevtools.stopDetectDevtools()
</script>

Configuration

detectDevtools.startDetectDevtools({
    // time between pulses, which are sent from the webworker
    millisecondsBetweenPulse: 50,

    // the threshhold to detect if a pulse is missing. 
    // should be higher than millisecondsBetweenPulse, otherwise there will be false positives
    millisecondsLastPulseThreshhold: 100,
    
    // time between updating the detectDevtools object. 
    // its best to keep it the same value as millisecondsBetweenPulse
    millisecondsBetweenUpdate: 50,
    
    // time between the webworker gets restarted. This will rejump to the debugger statement, as a new Webworker gets started.
    // this can set really low to make devtools jump every x milliseconds to a debugger, which makes navigating in the devtools a pain/impossible. (There is probably an option to disable jumping to a debugger statement)
    millisecondsBetweenWorkerRestart: 100000000,
})

Example configurations

default

detectDevtools.startDetectDevtools({
    millisecondsBetweenPulse: 50,
    millisecondsLastPulseThreshhold: 100, // this should be higher than millisecondsBetweenPulse, otherwise there will be false positives
    millisecondsBetweenUpdate: 50,
    millisecondsBetweenWorkerRestart: 100000000,
})

fast detection

detectDevtools.startDetectDevtools({
    millisecondsBetweenPulse: 10,
    millisecondsLastPulseThreshhold: 40, // this should be higher than millisecondsBetweenPulse, otherwise there will be false positives
    millisecondsBetweenUpdate: 50,
    millisecondsBetweenWorkerRestart: 100000000,
})

slow detection

detectDevtools.startDetectDevtools({
    millisecondsBetweenPulse: 100,
    millisecondsLastPulseThreshhold: 200, // this should be higher than millisecondsBetweenPulse, otherwise there will be false positives
    millisecondsBetweenUpdate: 50,
    millisecondsBetweenWorkerRestart: 100000000,
})
1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago