Skip to content
/ eruda Public
forked from liriliri/eruda

Console for mobile browsersEruda 是一个专为手机网页前端设计的调试面板,类似 DevTools 的迷你版,其主要功能包括:捕获 console 日志、检查元素状态、显示性能指标、捕获XHR请求、显示本地存储和 Cookie 信息、浏览器特性检测等等。

License

Notifications You must be signed in to change notification settings

umphp/eruda

Repository files navigation

中文

Eruda

NPM version Build status License

Console for Mobile Browsers.

Eruda

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

Browse it on your phone: http://liriliri.github.io/eruda/

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

javascript:(function () { var script = document.createElement('script'); script.src="//liriliri.github.io/eruda/eruda.min.js"; document.body.appendChild(script); script.onload = function () { eruda.init() } })();

Features

  • Console: Display JavaScript logs.
  • Elements: Check dom state.
  • Network: Show performance timing, ajax 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.
  • Features: Browser feature detections.

Install

You can get it on npm.

npm install eruda --save

Add this script to your page.

<script src="node_modules/eruda/eruda.min.js"></script>
<script>eruda.init();</script>

It's also available on jsDelivr and cdnjs.

<script src="//cdn.jsdelivr.net/eruda/1.2.0/eruda.min.js"></script>
<script>eruda.init();</script>

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:

;(function () {
    var src = 'node_modules/eruda/eruda.min.js';
    if (!/eruda=true/.test(window.location) && localStorage.getItem('active-eruda') != 'true') return;
    document.write('<scr' + 'ipt src="' + src + '"></scr' + 'ipt>');
    document.write('<scr' + 'ipt>eruda.init();</scr' + 'ipt>');
})();

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.
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.

When writing plugins, you can use utilities exposed by Eruda, see docs here.

Contribution

Read Contributing Guide for development setup instructions.

Related Projects

  • eustia: Generator of eruda's utility library.
  • freego: Http redirect proxy injecting eruda on every page.

About

Console for mobile browsersEruda 是一个专为手机网页前端设计的调试面板,类似 DevTools 的迷你版,其主要功能包括:捕获 console 日志、检查元素状态、显示性能指标、捕获XHR请求、显示本地存储和 Cookie 信息、浏览器特性检测等等。

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 84.1%
  • CSS 10.4%
  • HTML 5.4%
  • Shell 0.1%