• Stars
    star
    325
  • Rank 129,350 (Top 3 %)
  • Language
    JavaScript
  • Created over 11 years ago
  • Updated about 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Detect if the Chrome Inspector is open or closed.

Deprecation

As of August 20, 2013, this library no longer works in the latest stable build Google Chrome, due to a change to chrome.profiles. So it is now deprecated. We may try bring this library back as a Chrome Extension. Progress has already been made. – Adam

Chrome Inspector Detector

Demo

A simple utility for detecting whether or not the Chrome Inspector is open or docked.

Simply call chrome.inspector.detector() and you will be returned one of the following three objects:

  • When the inspector is opened and docked: { opened: true, docked: true }
  • When the inspector is opened and in a separate window: { opened: true, docked: false }
  • When the inspector is closed: { opened: false, docked: false }

You can also set up a watcher to watch for changes to the inspector state:

chrome.inspector.detector.watch(function(status){
    document.body.style.background = status.open ? 'red' : '';
});

Example on jsFiddle

Note: In order for docking detection to work, you must have html, body { height: 100%; width: 100% } in your CSS (or something similar) such that when the Inspector is closed document.height === document.body.clientHeight is true.

Things you could do with this that are not malicious :P

  • You're developing a JS game and you want to pause the game whenever you open the console so that it's easier to adjust CSS without it constantly re-rerendering.
  • You're designing a site and want to display a typography grid overlay whenever inspecting to aid in design.
  • You want a few dom nodes or JS objects to be console.log'd whenever you open the console for up-to-date information.

Credit goes to this Stackoverflow answer for the profiler technique.

More Repositories

1

magic-of-css

A CSS course to turn you into a magician.
CSS
6,626
star
2

log

Console.log with style.
HTML
3,012
star
3

chrome-tabs

Chrome-style tabs in HTML/CSS.
JavaScript
1,715
star
4

web.scraper.workers.dev

Scrape websites for text by CSS selector.
JavaScript
581
star
5

generate.invoice.workers.dev

Open-source tool for generate PDF invoices with Cloudflare Workers.
JavaScript
74
star
6

lazy.invoice.workers.dev

Lazily generate PDF using Cloudflare Workers.
JavaScript
71
star
7

letters

Draw non-overlapping text on a canvas
HTML
69
star
8

chrome-new-tab

New Tab page for Google Chrome
JavaScript
26
star
9

github-markdown-kitchen-sink

26
star
10

worker-generate-invoice-pdf

Generate an invoice PDF on the fly with Cloudflare Workers
JavaScript
23
star
11

chrome-chromeless

Chromeless Chrome
JavaScript
21
star
12

sci-fi-coder

The text effect used in Sci-Fi films.
JavaScript
12
star
13

chrome-console-grapher

Draw bar charts in the Chrome Developer Tools console.
JavaScript
12
star
14

get.svg.workers.dev

JavaScript
10
star
15

chrome-desaturate-favicons

Desaturate the favicons of all inactive tabs.
JavaScript
8
star
16

paste

Paste or drop anything
JavaScript
8
star
17

weather

HTML
4
star
18

REDLOVE

A border-radius font.
CSS
4
star
19

midigame

JavaScript
4
star
20

textual

A library for creating super-minimal contextual form elements.
CSS
4
star
21

playground

HTML
4
star
22

threedeeworld

Make any website feel a little 3d
JavaScript
4
star
23

chords

JavaScript
4
star
24

face

My face
3
star
25

chrome-style

Style the internet how you want.
JavaScript
3
star
26

terminal.js

terminal.js — a terrible idea
JavaScript
3
star
27

docs-engine-example

JavaScript
3
star
28

typography.js

HTML
2
star
29

focus-visible-polyfill

A modified version of https://github.com/WICG/focus-visible
JavaScript
2
star
30

mimic

Keep a copy of a DOM element in sync with an original
HTML
2
star
31

noise

Full color noise. (+ fun)
2
star
32

netflix-pause-indefinitely

Chrome extension to better handle Netflix’s “Playback Timed Out” errors.
JavaScript
2
star
33

example-site-editor

Example website using: https://github.com/adamschwartz/site-editor
HTML
2
star
34

tufte-d3-examples

Some D3 examples
JavaScript
2
star
35

site-editor

See an example: https://github.com/adamschwartz/example-site-editor
JavaScript
1
star
36

eager-chrome-extension

JavaScript
1
star
37

real-touch-messenger

A JS clone of WATCH’s Real Touch Messenger
JavaScript
1
star
38

devices

JavaScript
1
star
39

atom

My ~/.atom files
CSS
1
star
40

et-notebooks

Resources for ET Notebooks
HTML
1
star
41

logo

HTML
1
star
42

eager-brand

Brand guidelines for Eager.
1
star
43

giphy

Website version of Giphy's screensavers (http://giphy.com/screensavers).
HTML
1
star
44

EagerAppTestingShell

A shell for testing Eager apps.
1
star
45

responsive-url

https://adamschwartz.co/responsive-url/test/
JavaScript
1
star
46

commands

JavaScript
1
star
47

set-interval-visible

`setInterval` that pauses when the page isn’t visible
HTML
1
star