npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

console-panel

v1.0.4

Published

A console panel in webpage to help 3 use-cases: show console message automatically ; debug mobile ; debug IE/Edge

Downloads

3,683

Readme

console-panel

A console panel within web page to help in the following use-cases:

  • Get notification on console messages
  • Console logging on mobile and tablet devices
  • Console logging on Microsoft Edge / Internet Explorer (without opening native Developer Tools)

Demo

Click here to view online demo.

How to use

Files to include

Minimal setup

In your HTML file, add the following tags:

<link rel="stylesheet" href="console-panel.css" />
<script src="console-panel.js"></script>
<script>
    consolePanel.enable();
</script>

Full-featured setup

In your HTML file, add the following tags:

<!-- Optional: Required for resizing panel height -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/RickStrahl/[email protected]/dist/jquery-resizable.min.js"></script>

<!-- Optional: Required for logging arrays and objects -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/native-promise-only/0.8.1/npo.js"></script> <!-- Optional: A polyfill for native ES6 Promises (Not required for modern browsers) -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/5.26.2/jsoneditor.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/5.26.2/jsoneditor-minimalist.min.js"></script>

<!-- Optional: Required for logging DOM elements with syntax highlighting -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/themes/prism.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/prism.min.js" data-manual></script>

<!-- Required: Code for console-panel -->
<link rel="stylesheet" href="console-panel.css" />
<script src="console-panel.js"></script>
<script>
    consolePanel.enable();
</script>

API

consolePanel.enable(config)

This will initiate the interception logic based on the configuration options and activate console-panel as requested.

Configuration options

Summary: Position of console-panel's icon
Type: string
Supported positions: "top-left", "top-right", "bottom-left", "bottom-right"
Default value: "bottom-right"
Example value: "top-right"

Summary: List of console functions which should be intercepted
Type: <falsy-value> OR string "all" OR array (of strings)
Supported function names: "window.onerror", "console.error", "console.warn", "console.info", "console.log"
Default value: "all",
Example value: ["window.onerror", "console.error"]
Notes: console.clear() would always get intercepted when consolePanel.enable(config) is called

Summary: List of console function calls for which console-panel icon should be shown
Type: <falsy-value> OR string "all" OR array (of strings)
Supported function names: "window.onerror", "console.error", "console.warn", "console.info", "console.log"
Default value: null
Example value: ["window.onerror", "console.error", "console.warn"]
Notes: If it is a <falsy-value>, then console-panel notification icon would be shown all the time

Summary: List of console function calls for which console-panel notification should be shown strongly
Type: <falsy-value> OR array (of strings)
Supported function names: "window.onerror", "console.error", "console.warn", "console.info", "console.log"
Default value: ["window.onerror", "console.error"]
Example value: ["window.onerror", "console.error", "console.warn"]

Summary: When it is set as true, "strong-notification" effect is not shown for errors for which stack trace is not available. This can be used to avoid highlighting errors which are occurring due to a cross-origin / third-party script.
Type: boolean
Allowed values: <falsy-value> OR <truthy-value>
Default value: false
Example value: false

Summary: When it is set as true, the corresponding code line is mentioned along with each console entry. When it is set as true, it may interrupt your debugging session if you are using the "Pause on caught exceptions" feature in browser DevTools
Type: boolean
Allowed values: <falsy-value> OR <truthy-value>
Default value: true
Example value: true

Summary: Disable console-panel if browser DevTools might be open within the tab
Type: boolean
Allowed values: <falsy-value> OR <truthy-value>
Default value: false
Example value: false
Reference: https://github.com/sindresorhus/devtools-detect#support

Summary: Customize the title for the "disable" button in console-panel
Type: string
Allowed values: Any non-empty string
Default value: "Disable for this instance"
Example value: "Disable\n(and keep disabled)"

Summary: Function to be called before performing the default action for "disable" button
Type: function
Example value: function () { localStorage['console-panel-status'] = 'disabled'; }
Notes: If this function returns boolean false, then the default action would not be performed

Examples

// Enable console-panel in default mode.
// Use this configuration for getting notified about console messages and
// debugging for mobile devices and IE/Edge.
consolePanel.enable();
// Intercept only error logs.
// Use this configuration to ensure that you don't miss out on any errors, while
// continuing to use native DevTools logger for all other log entries.
consolePanel.enable({
    functionsToIntercept: ['window.onerror', 'console.error']
});
// Do not use console-panel when browser's DevTools might be open in the tab.
// Use this configuration to avoid using console-panel when you are debugging
// with the help of native DevTools.
consolePanel.enable({
    doNotUseWhenDevToolsMightBeOpenInTab: true
});
// Hide console-panel icon by default. But, show it as soon as any console
// related message shows up.
// Use this configuration if you wish to avoid seeing the console-panel icon as
// long as it doesn't serve an important purpose.
consolePanel.enable({
    showOnlyForTheseRelevantMessages: 'all'
});
// Show strong notification for all console related messages.
// Use this configuration if you wish to catch any console messages missed out
// from code clean up.
consolePanel.enable({
    strongNotificationFor: 'all'
});
// Do not report the code lines for messages in console-panel.
// Use this configuration if you wish to use "Pause on caught exceptions"
// feature in browser DevTools (which would otherwise get interrupted by dummy
// errors thrown by console-panel to report the code lines accurately).
consolePanel.enable({
    reportLogLines: false
});
// Skip strong-notification effect for errors without stack trace.
// Use this configuration if you wish to ignore errors caused by cross-origin
// (usually third-party) scripts where stack traces are not available.
consolePanel.enable({
    skipStrongNotificationIfNoStackTrace: true
});
// Add custom logic around the "Disable for this instance" button.
// Use this configuration if you wish to disable console-panel and keep it
// disabled for future page loads.
if (localStorage['console-panel-status'] !== 'disabled') {
    consolePanel.enable({
        disableButtonTitle: 'Disable\n(and keep disabled)',
        beforeDisableButtonClick: function () {
            localStorage['console-panel-status'] = 'disabled';
        }
    });
}

consolePanel.disable()

If you wish to deactivate console-panel, run consolePanel.disable(). It will restore the intercepted functions to their original state.

Browser support

Google Chrome

Microsoft Edge (and Internet Explorer)

Mozilla Firefox

Opera

Limitations / notable behavior

  • console.clear() is always intercepted whenever consolePanel.enable() is called.
  • In Microsoft Edge (EdgeHTML) and Internet Explorer, the console functions are not intercepted if the browser's native Developer Tools are in activated state (window.onerror can still be intercepted). Also, for these browsers, if the native Developer Tools have been opened once, then the intercepted calls to the console logging function calls are absorbed (rather than intercepted).
  • During a page load, if consolePanel.enable(config) has already been called once, then calling consolePanel.enable(config_new) with a different config may not work well for all the cases.

TODO

TODO.md

Alternative solutions you may like

  • Android: https://developers.google.com/web/tools/chrome-devtools/remote-debugging/
  • iOS: https://github.com/google/ios-webkit-debug-proxy

A lightweight, extendable front-end developer tool for mobile web page (https://github.com/Tencent/vConsole)

In your HTML file, add the following tags:

<script src="https://getfirebug.com/firebug-lite.js"></script>
<script>
    firebug.init();
</script>

References:

  • https://blog.getfirebug.com/2013/08/21/firebug-1-12-0/
  • https://blog.getfirebug.com/2013/05/02/future-of-firebug-lite/
  • http://www.softwareishard.com/blog/planet-mozilla/how-to-start-with-firebug-lite/

About this project

Author

Connect to us

License