Eruda

Console for mobile browsers

README

Eruda


Console for Mobile Browsers.
[![NPM version][npm-image]][npm-url] [![Build status][ci-image]][ci-url] [![Test coverage][codecov-image]][codecov-url] [![Downloads][jsdelivr-image]][jsdelivr-url] [![License][license-image]][npm-url]


[npm-image]: https://img.shields.io/npm/v/eruda?style=flat-square
[npm-url]: https://npmjs.org/package/eruda
[jsdelivr-image]: https://img.shields.io/jsdelivr/npm/hm/eruda?style=flat-square
[jsdelivr-url]: https://www.jsdelivr.com/package/npm/eruda
[ci-image]: https://img.shields.io/github/workflow/status/liriliri/eruda/CI?style=flat-square
[ci-url]: https://github.com/liriliri/eruda/actions/workflows/main.yml
[codecov-image]: https://img.shields.io/codecov/c/github/liriliri/eruda?style=flat-square
[codecov-url]: https://codecov.io/github/liriliri/eruda?branch=master
[license-image]: https://img.shields.io/npm/l/eruda?style=flat-square
[donate-image]: https://img.shields.io/badge/$-donate-0070ba.svg?style=flat-square



Demo


Demo

Browse it on your phone: https://eruda.liriliri.io/

In order to try it for different sites, execute the script below on browser address bar.

  1. ``` js
  2. javascript:(function () { var script = document.createElement('script'); script.src="//cdn.jsdelivr.net/npm/eruda"; document.body.appendChild(script); script.onload = function () { eruda.init() } })();
  3. ```

Features


Console: Display JavaScript logs.
Elements: Check dom state.
Network: Show requests status.
Resource: Show localStorage, cookie information.
Info: Show url, user agent info.
Snippets: Include snippets used most often.
Sources: Html, js, css source viewer.

Install


You can get it on npm.

  1. ``` sh
  2. npm install eruda --save
  3. ```

Add this script to your page.

  1. ``` html
  2. <script src="node_modules/eruda/eruda.js"></script>
  3. <script>eruda.init();</script>
  4. ```

It's also available on jsDelivr and cdnjs.

  1. ``` html
  2. <script src="//cdn.jsdelivr.net/npm/eruda"></script>
  3. <script>eruda.init();</script>
  4. ```

The JavaScript file size is quite huge(about 100kb 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:

  1. ``` js
  2. ;(function () {
  3.     var src = '//cdn.jsdelivr.net/npm/eruda';
  4.     if (!/eruda=true/.test(window.location) && localStorage.getItem('active-eruda') != 'true') return;
  5.     document.write('<scr' + 'ipt src="' + src + '"></scr' + 'ipt>');
  6.     document.write('<scr' + 'ipt>eruda.init();</scr' + 'ipt>');
  7. })();
  8. ```

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.

For more information, please check the documentation.

  1. ``` js
  2. let el = document.createElement('div');
  3. document.body.appendChild(el);

  4. eruda.init({
  5.     container: el,
  6.     tool: ['console', 'elements']
  7. });
  8. ```

Plugins


eruda-fps: Display page fps info.
eruda-features: Browser feature detections.
eruda-timing: Show performance and resource timing.
eruda-memory: Display page memory info.
eruda-code: Run JavaScript code.
eruda-benchmark: Run JavaScript benchmarks.
eruda-geolocation: Test geolocation.
eruda-dom: Navigate dom tree.
eruda-orientation: Test orientation api.
eruda-touches: Visualize screen touches.

If you want to create a plugin yourself, follow the guides here.

Related Projects


chii: Remote debugging tool.
chobitsu: Chrome devtools protocol JavaScript implementation.
licia: Utility library used by eruda.
eruda-webpack-plugin: Eruda webpack plugin.

Backers



Contribution


Read Contributing Guide for development setup instructions.