Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

theroomjs

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

theroomjs

a vanilla javascript plugin that allows you to outline dom elements like web inspectors

  • 2.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

theroomjs

A vanilla javascript plugin that allows you to outline DOM elements like web inspectors.

Downloads install size

theroomjs can be accessable globally as theRoom. It's compatible with modern browsers such as Google Chrome, Mozilla Firefox, Safari, Edge and Internet Explorer.

Install

$ npm install theroomjs --save

Usage

  // setup/configure theRoom before inspection
  // this configurations can be passed in 'start' event as well
  window.theRoom.configure({
    inspector: '.inspector-element',
    blockRedirection: true,
    excludes: ['footer'],
    click: function (element) {
      console.log('element is clicked:', element)
    }
  })

  // start inspection
  window.theRoom.start()

  // dynamically bind event
  window.theRoom.on('mouseover', function (element) {
    console.log('the element is hovered', element)
  })

  // stop inspection
  // and reset inspector styles
  window.theRoom.stop(true)

  // dont emit mouseover and click events
  // if the target element id is 'yusufHayaloglu'
  window.theRoom.on('hook', function (event) {
    if (event.target.id === 'yusufHayaloglu') {
      return false
    }
  })

  console.log(
    window.theRoom.status() // will print out -> stopped
  )

Options

NameTypeDefaultDescription
inspectorstring or DOM node-Placeholder element for inspection. It will not be inspected
createInspectorbooleanfalseIf true and inspector option is not provided, theRoom will try to create an inspector element whose class is inspector-element for you and will be appended to <body/>
htmlClassbooleantrueIf true theRoom's namespace will be automatically added to <html/> element class list
blockRedirectionbooleanfalseIf true the page will not be redirected elsewhere. theRoom will override onbeforeunload to do that
excludesarray (string)-Elements that excluded for inspection. Basic CSS selectors are allowed. For more information please see document.querySelector

Events

NameDescription
startingFired when inspection is being started
startedFired when inspection is started
stoppingFired when inspection is being stopped
stoppedFired when inspection is stopped
clickFired when the inspected element is clicked. The element is passed as the first argument, Event passed as the second argument
mouseoverFired when the inspected element mouseovered. The element is passed as the first argument, Event passed as the second argument
hookFired before click and mouseover events. Event passed as the only argument. mouseover and click events wont be emitted if the hook event returns false

Events can also be defined in options.

theRoom object

theRoom global object exposes those:

OptionTypeParametersDescription
onfunctionevent name and handler functionTo dynamically event binding
startfunctionoptions (optional)To start inspection
stopfunctionresetInspector (optional)To stop inspection
configurefunctionoptionsTo override theRoom option(s) anytime
statusfunction-Gets inspection engine status. Can be idle, running and stopped
  • path-finder - A Chrome extension to inspect and find out an HTML element unique CSS selector

Keywords

FAQs

Package last updated on 23 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc