• Stars
    star
    324
  • Rank 126,925 (Top 3 %)
  • Language
    JavaScript
  • Created over 11 years ago
  • Updated almost 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,630
star
2

log

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

chrome-tabs

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

web.scraper.workers.dev

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

generate.invoice.workers.dev

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

lazy.invoice.workers.dev

Lazily generate PDF using Cloudflare Workers.
JavaScript
70
star
7

letters

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

chrome-new-tab

New Tab page for Google Chrome
JavaScript
26
star
9

github-markdown-kitchen-sink

26
star
10

chrome-chromeless

Chromeless Chrome
JavaScript
21
star
11

worker-generate-invoice-pdf

Generate an invoice PDF on the fly with Cloudflare Workers
JavaScript
20
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
7
star
17

weather

HTML
4
star
18

REDLOVE

A border-radius font.
CSS
4
star
19

midigame

JavaScript
4
star
20

threedeeworld

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

chords

JavaScript
4
star
22

my-style

My Style is a Google Chrome extension that allows you to insert custom CSS into pages, immediately see the visual results, and have that CSS persist for future visits.
JavaScript
4
star
23

textual

A library for creating super-minimal contextual form elements.
CSS
3
star
24

face

My face
3
star
25

chrome-style

Style the internet how you want.
JavaScript
3
star
26

docs-engine-example

JavaScript
3
star
27

playground

HTML
3
star
28

focus-visible-polyfill

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

mimic

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

noise

Full color noise. (+ fun)
2
star
31

terminal.js

terminal.js — a terrible idea
JavaScript
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

eager-chrome-extension

JavaScript
1
star
36

site-editor

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

typography.js

HTML
1
star
38

real-touch-messenger

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

devices

JavaScript
1
star
40

atom

My ~/.atom files
CSS
1
star
41

et-notebooks

Resources for ET Notebooks
HTML
1
star
42

giphy

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

EagerAppTestingShell

A shell for testing Eager apps.
1
star
44

responsive-url

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

commands

JavaScript
1
star
46

set-interval-visible

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

refineslide

A 3D transform/CSS transition-enabled jQuery plugin for displaying responsive, image-based content with shiny animations.
JavaScript
1
star