Completed
Push — master ( 64ea05...ec8aaf )
by Vinicius
03:02
created

warning.js ➔ ... ➔ ?!?.map   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
c 1
b 1
f 0
nc 1
dl 0
loc 3
rs 10
nop 1
1
'use strict'
2
3
const warning = function () {
4
  const i = 'Stop!'
5
  const j = 'This is a developer-facing browser feature. Be aware that your account may be compromised by the unknown code use here.'
6
  const k = ['See https://en.wikipedia.org/wiki/Self-XSS for more information.']
7
  if (window.chrome || window.safari) {
8
    const l = 'font-family:helvetica; font-size:20px; ';
9
    [[i, l + 'font-size:50px; font-weight:bold; ' + 'color:red; -webkit-text-stroke:1px black;'], [j, l], [k, l], ['', '']].map(function (r) {
10
      setTimeout(console.log.bind(console, '\n%c' + r[0], r[1]))
11
    })
12
  }
13
}
14
15
let i = 0
16
function showWarningAndThrow () {
17
  if (!i) {
18
    setTimeout(function () {
19
      warning()
20
    }, 1)
21
    i = 1
22
  }
23
}
24
25
let l
26
let n = {
27
  set (o) {
28
    l = o
29
  },
30
  get () {
31
    showWarningAndThrow()
32
    return l
33
  }
34
}
35
36
Object.defineProperty(console, '__commandLineAPI', n)
37
const threshold = 160
38
39
setInterval(function () {
40
  const widthThreshold = this.outerWidth - this.innerWidth > threshold
41
  const heightThreshold = this.outerHeight - this.innerHeight > threshold
42
43
  if (!(heightThreshold && widthThreshold) && ((this.Firebug && this.Firebug.chrome && this.Firebug.chrome.isInitialized) || widthThreshold || heightThreshold)) {
44
    void console.__commandLineAPI
45
  } else {
46
    console.clear()
47
    i = 0
48
  }
49
})
50