[中文](doc/README_CN.md) # Eruda [![Join the chat at https://gitter.im/liriliri/eruda][gitter-image]][gitter-url] [![NPM version][npm-image]][npm-url] [![Build status][travis-image]][travis-url] [![Test coverage][codecov-image]][codecov-url] [![License][license-image]][npm-url] [gitter-image]: https://badges.gitter.im/liriliri/eruda.svg [gitter-url]: https://gitter.im/liriliri/eruda?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge [npm-image]: https://img.shields.io/npm/v/eruda.svg [npm-url]: https://npmjs.org/package/eruda [travis-image]: https://img.shields.io/travis/liriliri/eruda.svg [travis-url]: https://travis-ci.org/liriliri/eruda [codecov-image]: https://codecov.io/github/liriliri/eruda/coverage.svg?branch=master [codecov-url]: https://codecov.io/github/liriliri/eruda?branch=master [license-image]: https://img.shields.io/npm/l/eruda.svg Console for Mobile Browsers. ![Eruda](http://7xn2zy.com1.z0.glb.clouddn.com/eruda_screenshot4.jpg) ## Why Logging things out on mobile browser is never an easy stuff. I used to include `window onerror alert` script inside pages to find out JavaScript errors, kind of stupid and inefficient. Desktop browser DevTools is great, and I wish there is a similar one on mobile side, which leads to the creation of Eruda. ## Demo ![Demo](http://7xn2zy.com1.z0.glb.clouddn.com/eruda_qrcode3.png) Browse it on your phone: [http://eruda.liriliri.io/](http://eruda.liriliri.io/) In order to try it for different sites, execute the script below on browser address bar. ```javascript javascript:(function () { var script = document.createElement('script'); script.src="//cdn.jsdelivr.net/npm/eruda"; document.body.appendChild(script); script.onload = function () { eruda.init() } })(); ``` ## Features * [Console](doc/TOOL_API.md#console): Display JavaScript logs. * [Elements](doc/TOOL_API.md#elements): Check dom state. * [Network](doc/TOOL_API.md#network): Show requests status. * [Resource](/doc/TOOL_API.md#resources): Show localStorage, cookie information. * [Info](doc/TOOL_API.md#info): Show url, user agent info. * [Snippets](doc/TOOL_API.md#snippets): Include snippets used most often. * [Sources](doc/TOOL_API.md#sources): Html, js, css source viewer. ## Install You can get it on npm. ```bash npm install eruda --save ``` Add this script to your page. ```html ``` It's also available on [jsDelivr](http://www.jsdelivr.com/projects/eruda) and [cdnjs](https://cdnjs.com/libraries/eruda). ```html ``` The JavaScript file size is quite huge(about 90kb gzipped) and therefore not suitable to include in mobile pages. It's recommended to make sure eruda is loaded only when eruda is set to true on url(http://example.com/?eruda=true), for example: ```javascript ;(function () { var src = 'node_modules/eruda/eruda.min.js'; if (!/eruda=true/.test(window.location) && localStorage.getItem('active-eruda') != 'true') return; document.write(''); document.write('eruda.init();'); })(); ``` ## Configuration When initialization, a configuration object can be passed in. * container: Container element. If not set, it will append an element directly under html root element. * tool: Choose which default tools you want, by default all will be added. ```javascript var el = document.createElement('div'); document.body.appendChild(el); eruda.init({ container: el, tool: ['console', 'elements'] }); ``` ## Plugins It is possible to enhance Eruda with more features by writing plugins. Check source code of plugins below to learn how to write your own custom tool panels. Besides, [eruda-plugin](https://github.com/liriliri/eruda-plugin) is available for plugin initialization. * [eruda-fps](https://github.com/liriliri/eruda-fps): Display page fps info. * [eruda-features](https://github.com/liriliri/eruda-features): Browser feature detections. * [eruda-timing](https://github.com/liriliri/eruda-timing): Show performance and resource timing. * [eruda-memory](https://github.com/liriliri/eruda-memory): Display page memory info. * [eruda-code](https://github.com/liriliri/eruda-code): Run JavaScript code. When writing plugins, you can use utilities exposed by Eruda, see [docs](doc/UTIL_API.md) here. ## Contribution Read [Contributing Guide](doc/CONTRIBUTING.md) for development setup instructions. ## Related Projects * [eustia](https://github.com/liriliri/eustia): Generator of eruda's utility library. * [freego](https://github.com/surunzi/freego): Http redirect proxy injecting eruda on every page.