Detect F12 open console, protect web static resources, support redirect, rewrite, callback strategies.

Overview

console-ban

Detect F12 open browser console. protect web site static resources, support redirect, rewrite, custom callback strategies.

Language: English|中文|日本語

Usage

In html:

<head>
  <!-- ... -->
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/console-ban.min.js"></script>
  <script>
    // default options
    ConsoleBan.init()
    // custom options
    ConsoleBan.init({
      redirect: '/404'
    })
  </script>
</head>

Or in bundle project:

  yarn add console-ban
import { init } from 'console-ban'

init(options)

Strategy

Redirect

ConsoleBan.init({
  // Redirect to /404 relative url
  redirect: '/404',
  // Redirect to absolute url
  redirect: 'http://domain.com/path'
})

Use redirect to guide users to a site introduction page or a purely static 404 page

P.S. In SPA route push scene, detect will not take effect again.

Rewrite

var div = document.createElement('div')
div.innerHTML = 'Stop'

ConsoleBan.init({
  // Rewrite the <body></body> as a string
  write: '<h1> Stop </h1>',
  // or rewrite a element
  write: div
})

Rewriting strategies can completely block web site content, but are less friendly and are not recommended.

Custom callback

ConsoleBan.init({
  callback: () => {
    // ...
  }
})

The callback function supports custom policies after the console is opened.

Options

name required type default description
clear no boolean true Disable console.clear
debug no boolean true Whether to enable infinity debugger
debugTime no number 3000 The debugger execution interval
redirect no string - Redirect url when console is opend
write no string | Element - Rewrite document.body content when console is opend
callback no Function - Custom callback when console is opend

P.S. redirect, write, callback only one will work, priority use callback.

Support

browser core support
chrome
firefox
safari
You might also like...

Detect webpage updates and notify user to reload. support vite and umijs

English | 简体中文 plugin-web-update-notification Detect webpage updates and notify user to reload. support vite and umijs. Take the git commit hash as th

Dec 26, 2022

Gofiber with NextJS Static HTML is a small Go program to showcase for bundling a static HTML export of a Next.js app

Gofiber and NextJS Static HTML Gofiber with NextJS Static HTML is a small Go program to showcase for bundling a static HTML export of a Next.js app. R

Jan 22, 2022

🛡 Protect yourself from crypto scams online

Revoke.cash Browser Extension In many cases, phishing websites try to make you sign a token allowance while they pretend to be an NFT mint or other le

Dec 5, 2022

🔐 Protect your Smart Contract Proxy from storage collisions upon upgrading, by running this action in a CI on each of your Pull Requests!

🔥 🛠️ Foundry Storage Upgrade Seatbelt Protect your Smart Contract Proxy from storage collisions upon upgrading, by running this action in a CI on ea

Dec 24, 2022

Query for CSS brower support data, combined from caniuse and MDN, including version support started and global support percentages.

css-browser-support Query for CSS browser support data, combined from caniuse and MDN, including version support started and global support percentage

Nov 2, 2022

Cypress commands are asynchronous. It's a common pattern to use a then callback to get the value of a cypress command

cypress-thenify Rationale Cypress commands are asynchronous. It's a common pattern to use a then callback to get the value of a cypress command. Howev

Oct 2, 2022

Simple patch that adds a 'progress' callback to jquery Ajax calls

Jquery Ajax Progresss A simple patch to jQuery that will call a 'progress' callback, using the XHR.onProgress event Usage Simply include the script on

Sep 8, 2022

JavaScript micro-library: pass in an element and a callback and this will trigger when you click anywhere other than the element

Add a click listener to fire a callback for everywhere on the window except your chosen element. Installation run npm install @lukeboyle/when-clicked-

May 13, 2021

Plug-and-play, faster-than-native promise/callback event emitter

Plug-and-play, faster-than-native promise/callback event emitter

kNow Blazing-fast callback/promise-based events with a tiny footprint What is this? With kNow (pronounced "now"—the k's silent), JavaScript event mana

Sep 11, 2022
Releases(v4.1.0)
Owner
Yingci
𝑭𝒐𝒍𝒍𝒐𝒘 𝒚𝒐𝒖𝒓 𝒉𝒆𝒂𝒓𝒕
Yingci
A lightweight extension to automatically detect and provide verbose warnings for embedded iframe elements in order to protect against Browser-In-The-Browser (BITB) attacks.

Enhanced iFrame Protection - Browser Extension Enhanced iFrame Protection (EIP) is a lightweight extension to automatically detect and provide verbose

odacavo 16 Dec 24, 2022
Incredible resources (with links) to help up-skill yourselves on various fields. Resources like programming, designing, engineering and much more and completely Open Source.

Shiryoku Incredible resources (with links) to help up-skill yourselves on various fields. Resources like programming, designing, engineering and much

Kunal Keshan 22 Dec 15, 2022
Manage GitHub resources like repositories, teams, members, integrations and workflows with the AWS CDK as Custom Resources in CloudFormation.

CDK Github Manage GitHub resources like repositories, teams, members, integrations and workflows with the AWS CDK as Custom Resources in CloudFormatio

Pepperize 8 Nov 25, 2022
A collection of social media strategies for remix-auth

Remix Auth Socials A collection of Remix Auth strategies for Oauth2 Social logins. ?? If you are interested in creating one of the planned strategies,

Tom Rowe 80 Jan 5, 2023
FACEIT (OAuth2) authentication strategies for Passport.

passport-faceit FACEIT is a trademark or registered trademark of FACEIT LIMITED in the U.S. and/or other countries. "@ambergg/passport-faceit" is not

Amber.gg 5 Oct 26, 2022
It's a set of common utility strategies to work with responsive styles with Flutter and CSS in JS

@skynexui/responsive_stylesheet You don't need to be worried just because you have to support multiple screens ?? ?? ?? ?? It's a set of common utilit

SkynexUI 40 Oct 26, 2022
A Rust rewrite of Flameboi that will be more approachable for new developers to contribute to.

Devil Bot Rust Overview A Rust implementation of a Slack bot that will be used by the CodeDevils Slack workspace. All resources are managed using AWS

CodeDevils 11 Dec 21, 2022
A Nest rewrite of crystal, the SOS Discord bot

crystal-nest A Nest rewrite of crystal, the SOS Discord bot Explore the docs » Report Bug · Request Feature Table of Contents About The Project Built

PR1SM 5 Dec 22, 2022
A simple JS example for NextAuth Google login with a popup window instead of redirect.

A simple JS example for NextAuth Google login with a popup window instead of redirect.

null 13 Dec 7, 2022
Rewrite of revoltchat/revite.

Solid App (name TBD) This is still a work in progress, please do not create any issues and clear any PRs with me ahead of time. See code style guideli

Revolt 17 Jan 7, 2023