GithubHelp home page GithubHelp logo

brabeji / dom-inspector Goto Github PK

View Code? Open in Web Editor NEW

This project forked from luoye-fe/dom-inspector

0.0 1.0 0.0 309 KB

Dom inspect like chrome dev tools.

License: MIT License

JavaScript 83.66% CSS 7.32% HTML 9.01%

dom-inspector's Introduction

DomInspector

Dom inspector like chrome dev tools.

Usage

Install dom-inspector

npm install dom-inspector --save
<script type="text/javascript" src="./dist/dom-inspector.min.js"></script>
const DomInspector = require('dom-inspector');
import DomInspector from 'dom-inspector';

New instance

const inspector = new DomInspector();

Instance options

const inspector = new DomInspector({
	root: 'body',
	exclude: ['#exclude>div', document.querySelector('.exclude')],
  theme: 'you-custom-theme-class',
  maxZIndex: '', // max z index, if blank, will auto get document.all max z index
});
  • root

    Dom inspector root element. String or Dom, default body.

  • exclude

    Not inspect some elements. String or Dom Array.

  • theme

    Inspector overlay style. You can custom overlay background color as follow.

     .you-custom-theme-class .margin {
     	background-color: blue;
     }
    
     .you-custom-theme-class .border {
     	background-color: red;
     }
    
     .you-custom-theme-class .padding {
     	background-color: green;
     }
    
     .you-custom-theme-class .content {
     	background-color: gray;
     }

    Don`t forget background color opacity. ^_^

Attribute list

  • inspector.target

    Inspecting element.

API list

  • inspector.enable()

    Display overlay block and addEventListener mousemove.

  • inspector.pause()

    RemoveEventListener mousemove, pause inspector.

  • inspector.disable()

    RemoveEventListener mousemove, display overlay none.

  • inspector.destroy()

    disable() and remove overlay.

  • inspector.getXPath([ele])

    Return ele XPath.

  • inspector.getSelector([ele])

    Return ele selector.

    html>body>div:nth-of-type(9)

  • inspector.getElementInfo([ele])

     return {
     	top: '',
     	left: '',
     	width: '',
     	height: '',
     	'padding-top': '',
     	'padding-right': '',
     	'padding-bottom': '',
     	'padding-left': '',
     	'border-top-width': '',
     	'border-right-width': '',
     	'border-bottom-width': '',
     	'border-left-width': '',
     	'margin-top': '',
     	'margin-right': '',
     	'margin-bottom': '',
     	'margin-left': ''
     };

dom-inspector's People

Contributors

dependabot[bot] avatar lumberman avatar luoye-fe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.