5.0.0 • Published 1 year ago

console-ban v5.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
1 year ago

console-ban

F12 ブラウザのコンソールを見破る、Web サイトのスタティックなリソースを保護し、リダイレクト、リライト、コールバック三つのストラテジーを通用が可能。

Language: English|中文|日本語

使い方

HTML に直接に挿入:

<head>
  <!-- ... -->
  <script src="https://cdn.jsdelivr.net/npm/console-ban@5.0.0/dist/console-ban.min.js"></script>
  <script>
    // デフォルトオプション
    ConsoleBan.init()
    // カスタムオプション
    ConsoleBan.init({
      redirect: '/404'
    })
  </script>
</head>

現代なウェブのプロジェクトにインストール:

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

init(options)

ストラテジー

リダイレクト

ConsoleBan.init({
  // 相対的な /404 目的にリダイレクト
  redirect: '/404',
  // 絶対的な目的地にリダイレクト
  redirect: 'http://domain.com/path'
})

リダイレクトを使ってユーザーをサイトの紹介ページまたは純粋にスタティックな 404 ページに誘導

注意:SPA プロジェクトにルートが変化の場合、再び効果を取らない

リライト

var div = document.createElement('div')
div.innerHTML = '見るな'

ConsoleBan.init({
  // 単純なストリングをページの body にリライト
  write: '<h1> 見るな </h1>',
  // あるいは、実在なエレメントを使うのが可能
  write: div
})

リライトは完全にウェブサイトの検査をブロックするのが可能、一方でユーザーに不気分な意味を混じる、推薦するの方がいいと言うことが言わない

コールバック

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

コールバックのオプションは自分でコンソールを開けて起きることを決めることができる

オプション

namerequiredtypedefaultdescription
clearnobooleantrueconsole.clear を禁止
debugnobooleantruedebugger を無限に実行するかどうか
debugTimenonumber3000定時に debugger を循環の間隔
redirectnostring-コンソールを開けてリダイレクトの目的地
writenostring | Element-コンソールを開けて document.body をリライトの内容
callbacknoFunction-コンソールを開けて自分で定義出来るコールバック
bfcachenobooleantruebfcache の能力を禁止

注意:redirectwritecallback 三つのストラテジーは唯一つが使うことが出来る,コールバックの優先位が一番高い

ブラウザの支持

browser coresupport
chrome
firefox
safari
5.0.0

1 year ago

4.1.0

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

3.2.0

3 years ago

3.1.0

3 years ago

3.0.0

3 years ago

2.2.0

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.1.0

3 years ago